/* Reset และ Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8fafc;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header with Background Image */
.header {
    position: relative;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.header-image {
    position: relative;
    height: 0;
    padding-bottom: 31.1%; /* 618/1986 * 100% = 31.1% */
    overflow: hidden;
}

.header-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    /* Fallback for older browsers */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Main Layout with Sidebar */
.main-layout {
    display: flex;
    min-height: 100vh;
    background-color: #f8fafc;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    color: white;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.sidebar-header {
    padding: 2rem 1.5rem 1rem;
    border-bottom: 1px solid #4a5568;
}

.sidebar-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #68d391;
    margin: 0;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.5rem;
    color: #e2e8f0;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    margin: 0;
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: #68d391;
}

.sidebar-link.active {
    background-color: rgba(104, 211, 145, 0.2);
    color: #68d391;
    border-left-color: #68d391;
}

.sidebar-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    color: #68d391;
}

.sidebar-link span {
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Hero Section - Updated */
.hero {
    background: linear-gradient(135deg, #e6fffa 0%, #f0fff4 100%);
    padding: 3rem 2rem;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

.hero-content h2 {
    font-size: 2rem;
    color: #2d3748;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.hero-content p {
    font-size: 1.1rem;
    color: #4a5568;
    margin-bottom: 1.5rem;
}

/* Dashboard Cards */
.dashboard-cards {
    padding: 3rem 2rem;
    background-color: #f8fafc;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border-top: 4px solid transparent;
}

.dashboard-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.card-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    color: white;
    position: relative;
}

.card-icon.green {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.card-icon.blue {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
}

.card-icon.orange {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
}

.card-icon.purple {
    background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%);
}

.card-icon.red {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
}

.card-icon.teal {
    background: linear-gradient(135deg, #38b2ac 0%, #319795 100%);
}

.dashboard-card h4 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.dashboard-card p {
    color: #718096;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.card-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #48bb78;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.card-link:hover {
    color: #38a169;
    gap: 12px;
}

.card-link i {
    transition: transform 0.3s ease;
}

.card-link:hover i {
    transform: translateX(4px);
}

/* Hover effects for different card types */
.dashboard-card:hover .card-icon.green {
    border-top-color: #48bb78;
}

.dashboard-card:hover .card-icon.blue {
    border-top-color: #4299e1;
}

.dashboard-card:hover .card-icon.orange {
    border-top-color: #ed8936;
}

.dashboard-card:hover .card-icon.purple {
    border-top-color: #9f7aea;
}

.dashboard-card:hover .card-icon.red {
    border-top-color: #f56565;
}

.dashboard-card:hover .card-icon.teal {
    border-top-color: #38b2ac;
}

/* Certificates Section - Updated */
.certificates {
    flex: 1;
    padding: 2rem;
}

.section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.section-header h3 {
    font-size: 1.8rem;
    color: #2d3748;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.section-header p {
    color: #718096;
    font-size: 1rem;
}

.certificates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Certificate Card */
.certificate-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.certificate-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.card-image {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.certificate-card:hover .card-image img {
    transform: scale(1.1);
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(72, 187, 120, 0.9), rgba(56, 161, 105, 0.9));
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.certificate-card:hover .card-overlay {
    opacity: 1;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-family: 'Sarabun', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: #48bb78;
    border: 2px solid #48bb78;
}

.btn-outline:hover {
    background: #48bb78;
    color: white;
}

.btn-download {
    background: white;
    color: #48bb78;
    font-size: 16px;
    padding: 16px 32px;
    border-radius: 50px;
}

.btn-download:hover {
    background: #f7fafc;
    transform: scale(1.05);
}

.card-content {
    padding: 24px;
}

.card-content h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 16px;
    line-height: 1.4;
}

.card-meta {
    margin-bottom: 20px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: #718096;
    font-size: 14px;
}

.meta-item i {
    color: #48bb78;
    width: 16px;
}

.card-actions {
    display: flex;
    gap: 12px;
}

.card-actions .btn {
    flex: 1;
    justify-content: center;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 2rem;
}

.page-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    color: #48bb78;
    text-decoration: none;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.page-link:hover,
.page-link.active {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border-color: transparent;
}

/* Footer */
.footer {
    background: #2d3748;
    color: white;
    padding: 3rem 0 1rem;
    margin: 0;
}

.footer-content {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-info h4 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #68d391;
}

.footer-info p {
    color: #cbd5e0;
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-links a {
    color: #cbd5e0;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: #68d391;
}

.footer-bottom {
    border-top: 1px solid #4a5568;
    padding-top: 1rem;
    text-align: center;
    color: #a0aec0;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 250px;
    }
    
    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 0;
    }
    
    .sidebar-link {
        flex-shrink: 0;
        padding: 1rem;
        border-left: none;
        border-bottom: 4px solid transparent;
        text-align: center;
        min-width: 120px;
    }
    
    .sidebar-link:hover,
    .sidebar-link.active {
        border-bottom-color: #68d391;
        border-left-color: transparent;
    }
    
    .sidebar-link span {
        font-size: 0.8rem;
        display: block;
        margin-top: 4px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .header-image {
        padding-bottom: 38%; /* เพิ่มเล็กน้อยบนมือถือเพื่อให้เห็นรายละเอียดได้ดี */
    }
    
    .main-layout {
        min-height: calc(100vh - 38vw);
    }
    
    .sidebar {
        height: calc(100vh - 38vw);
        width: 100%;
        min-height: auto;
        position: relative;
    }
    
    .hero-nav {
        flex-direction: column;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }
    
    .nav-menu {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-brand h1 {
        font-size: 1.3rem;
    }
    
    .hero {
        padding: 2rem 1rem;
    }
    
    .hero-content h2 {
        font-size: 1.5rem;
    }
    
    .certificates-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .certificates {
        padding: 1.5rem;
    }
    
    .dashboard-cards {
        padding: 2rem 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
    
    .dashboard-card {
        padding: 1.5rem;
    }
    
    .card-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .dashboard-card h4 {
        font-size: 1.1rem;
    }
    
    .dashboard-card p {
        font-size: 0.9rem;
    }
    
    .sidebar-header {
        padding: 1rem;
    }
    
    .sidebar-link {
        padding: 0.8rem;
        min-width: 100px;
    }
    
    .sidebar-link span {
        font-size: 0.75rem;
        line-height: 1.2;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .card-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .header-image {
        padding-bottom: 42%; /* ปรับให้เหมาะสมบนมือถือขนาดเล็ก */
    }
    
    .hero {
        padding: 1.5rem 1rem;
    }
    
    .hero-nav {
        margin-bottom: 1.5rem;
    }
    
    .nav-brand h1 {
        font-size: 1.1rem;
    }
    
    .nav-link {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
    
    .hero-content h2 {
        font-size: 1.3rem;
    }
    
    .search-box {
        flex-direction: column;
        border-radius: 12px;
    }
    
    .search-box input {
        border-radius: 12px 12px 0 0;
        padding: 12px 16px;
    }
    
    .search-box button {
        border-radius: 0 0 12px 12px;
        padding: 12px;
    }
    
    .certificates {
        padding: 1rem;
    }
    
    .dashboard-cards {
        padding: 1.5rem 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .dashboard-card {
        padding: 1.5rem;
    }
    
    .certificate-card {
        margin-bottom: 1rem;
    }
    
    .sidebar-nav {
        padding: 0.5rem 0;
    }
    
    .sidebar-link {
        padding: 0.6rem 0.5rem;
        min-width: 80px;
    }
    
    .sidebar-link i {
        font-size: 1rem;
    }
    
    .sidebar-link span {
        font-size: 0.7rem;
    }
}

/* Mobile Menu Toggle */
@media (max-width: 768px) {
    .sidebar {
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        position: fixed;
        top: 38vw;
        left: 0;
        right: 0;
        z-index: 1000;
        height: auto;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }
    
    .sidebar.active {
        transform: translateY(0);
    }
    
    .main-content {
        margin-top: 0;
    }
    
    /* Add menu toggle button */
    .menu-toggle {
        position: fixed;
        top: calc(38vw + 20px);
        right: 20px;
        z-index: 1001;
        background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
        color: white;
        border: none;
        padding: 12px;
        border-radius: 50%;
        font-size: 18px;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
        transition: all 0.3s ease;
    }
    
    .menu-toggle:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 20px rgba(72, 187, 120, 0.6);
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-radius: 50%;
    border-top-color: #48bb78;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Success/Error Messages */
.message {
    padding: 16px 24px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.message.success {
    background: #f0fff4;
    color: #22543d;
    border: 1px solid #c6f6d5;
}

.message.error {
    background: #fef5e7;
    color: #744210;
    border: 1px solid #fbd38d;
}

/* Responsive Design สำหรับ Sidebar */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        min-height: auto;
        position: relative;
    }
    
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 1rem;
        gap: 0.5rem;
    }
    
    .sidebar-link {
        flex-shrink: 0;
        min-width: 200px;
        border-left: none;
        border-bottom: 4px solid transparent;
        border-radius: 8px;
        margin: 0 0.5rem;
    }
    
    .sidebar-link:hover {
        border-left: none;
        border-bottom-color: #68d391;
    }
    
    .sidebar-link.active {
        border-left: none;
        border-bottom-color: #68d391;
    }
    
    .main-content {
        min-height: auto;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
    }
    
    .sidebar-nav {
        flex-direction: column;
        gap: 0;
    }
    
    .sidebar-link {
        min-width: auto;
        margin: 0;
        border-bottom: none;
        border-left: 4px solid transparent;
    }
    
    .sidebar-link:hover {
        border-bottom: none;
        border-left-color: #68d391;
    }
    
    .sidebar-link.active {
        border-bottom: none;
        border-left-color: #68d391;
    }
}
