/* ==================== 
   CSS Variables & Reset 
   ==================== */
:root {
    /* Colors - โทนสีสุภาพ SaaS */
    --primary: #4F46E5;        /* Indigo - สีหลัก */
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    
    --bg-main: #F9FAFB;        /* พื้นหลังหลัก */
    --bg-white: #FFFFFF;
    --bg-sidebar: #1F2937;     /* Sidebar สีเข้ม */
    
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --text-white: #FFFFFF;
    
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    
    /* Status Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --sidebar-width: 260px;
    --header-height: 80px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Utility */
.hidden {
    display: none !important;
}

/* ==================== 
   LOGIN PAGE 
   ==================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
    text-align: center;
}

/* Logo Section */
.login-logo {
    margin-bottom: 32px;
    color: var(--text-white);
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.tagline {
    font-size: 16px;
    opacity: 0.9;
}

/* Login Card */
.login-card {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.login-card h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Google Login Button */
.google-login-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--bg-white);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.google-login-btn:hover {
    background: var(--bg-main);
    border-color: var(--text-light);
    box-shadow: var(--shadow-md);
}

.google-icon {
    flex-shrink: 0;
}

/* Divider */
.login-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-light);
    font-size: 14px;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.login-divider span {
    padding: 0 16px;
}

/* Login Note */
.login-note {
    font-size: 14px;
    color: var(--text-secondary);
}

.login-note a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.login-note a:hover {
    text-decoration: underline;
}

/* Features Preview */
.features-preview {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-white);
    font-size: 14px;
    opacity: 0.9;
}

.feature-icon {
    font-size: 18px;
}

/* ==================== 
   DASHBOARD PAGE 
   ==================== */
.dashboard-page {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-icon-small {
    font-size: 24px;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-light);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
}

.nav-item.active {
    background: var(--primary);
    color: var(--text-white);
}

.nav-icon {
    font-size: 18px;
}

.nav-text {
    font-size: 14px;
    font-weight: 500;
}

/* Sidebar User */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
}

.user-plan {
    font-size: 12px;
    color: var(--text-light);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
}

/* ==================== 
   MAIN CONTENT 
   ==================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    background: var(--bg-main);
    min-height: 100vh;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary);
    color: var(--text-white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-white);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--primary-light);
}

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.blue { background: #DBEAFE; }
.stat-icon.green { background: #D1FAE5; }
.stat-icon.orange { background: #FEF3C7; }
.stat-icon.purple { background: #EDE9FE; }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Section Title */
.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

/* Tools Grid */
.quick-actions-section {
    margin-bottom: 32px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.tool-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.tool-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.tool-icon {
    font-size: 36px;
    margin-bottom: 16px;
}

.tool-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.tool-card p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Recent Activity */
.recent-section {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.activity-list {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.activity-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.activity-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.activity-time {
    font-size: 12px;
    color: var(--text-light);
}

.activity-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.activity-status.published {
    background: #D1FAE5;
    color: #059669;
}

.activity-status.draft {
    background: #FEF3C7;
    color: #D97706;
}

/* ==================== 
   RESPONSIVE (Desktop Focus) 
   ==================== */
@media (max-width: 1200px) {
    .stats-section,
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }
    
    .sidebar-logo .logo-text,
    .nav-text,
    .user-info {
        display: none;
    }
    
    .sidebar-logo {
        justify-content: center;
    }
    
    .nav-item {
        justify-content: center;
    }
    
    .main-content {
        margin-left: 70px;
    }
    
    .stats-section,
    .tools-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== 
   ADMIN SETTINGS SECTION 
   ==================== */
.admin-settings-section {
    margin-top: 0;
}

.admin-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.admin-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.admin-table-container {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.admin-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    background: var(--bg-main);
}

.admin-table td {
    font-size: 14px;
    color: var(--text-primary);
}

.admin-empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Admin Status Badge */
.admin-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.admin-status-badge.pending {
    background: #FEF3C7;
    color: #92400E;
}

.admin-status-badge.approved {
    background: #D1FAE5;
    color: #065F46;
}

.admin-status-badge.rejected {
    background: #FEE2E2;
    color: #991B1B;
}

/* Admin Action Buttons */
.admin-btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.admin-btn-approve {
    background: var(--success);
    color: var(--text-white);
}

.admin-btn-approve:hover {
    background: #059669;
}

.admin-btn-reject {
    background: var(--error);
    color: var(--text-white);
    margin-left: 8px;
}

.admin-btn-reject:hover {
    background: #DC2626;
}

/* Admin Toast */
.admin-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: var(--text-white);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

.admin-toast.show {
    opacity: 1;
}


/* ==================== 
   UNAUTHORIZED SECTION (ภายใน Dashboard)
   ==================== */
.unauthorized-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 100px);
}

.unauthorized-card {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.unauthorized-icon {
    font-size: 56px;
    margin-bottom: 24px;
}

.unauthorized-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.unauthorized-description {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.unauthorized-email-box {
    background: var(--bg-main);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.unauthorized-email-label {
    font-size: 12px;
    color: var(--text-light);
}

.unauthorized-email-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.unauthorized-status-box {
    background: #FEF3C7;
    color: #92400E;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 24px;
}

.unauthorized-status-box.rejected {
    background: #FEE2E2;
    color: #991B1B;
}

.unauthorized-request-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--success);
    color: var(--text-white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.unauthorized-request-btn:hover {
    background: #059669;
}

.unauthorized-request-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

.unauthorized-request-btn.hidden {
    display: none;
}

/* ==================== 
   UNAUTHORIZED PAGE (แยกหน้า - นอก Dashboard)
   ==================== */
.unauthorized-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.unauthorized-container {
    width: 100%;
    max-width: 440px;
}

.unauthorized-page .unauthorized-card {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow: var(--shadow-lg);
}

.unauthorized-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--primary);
    color: var(--text-white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: 12px;
}

.unauthorized-logout-btn:hover {
    background: var(--primary-hover);
}
