:root {
    --bg-color: #faf5ff; /* Subtle luxurious light purple */
    --card-bg: #ffffff;
    --primary: #6b21a8; /* Deep royal purple */
    --primary-hover: #581c87;
    --secondary: #d97706; /* Gold/Amber */
    --text-color: #2e1065; /* Very dark purple text */
    --text-light: #6b7280;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Platform Colors */
    --facebook: #1877f2;
    --tiktok: #000000;
    --shopee: #ee4d2d;
    --lazada: #0014ff;
    --line: #00b900;
    --live: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 50%, #faf5ff 100%);
    background-size: 200% 200%;
    animation: gradientMove 15s ease infinite;
    color: var(--text-color);
    line-height: 1.5;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Dashboard Glowing Orbs (แสงวิบวับ) */
.app-container::before, .app-container::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: 0;
    pointer-events: none; /* ป้องกันไม่ให้บังการคลิก */
    animation: floatOrbs 12s infinite alternate ease-in-out;
}

.app-container::before {
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.6) 0%, transparent 70%);
    top: -200px;
    left: 10%;
}

.app-container::after {
    width: 1000px;
    height: 1000px;
    background: radial-gradient(circle, rgba(232, 121, 249, 0.5) 0%, transparent 70%);
    bottom: -300px;
    right: -100px;
    animation-delay: -6s;
    animation-duration: 15s;
}

.sidebar {
    width: 260px;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 1;
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

/* Typography */
h1, h2, h3 {
    font-weight: 700;
    color: var(--text-color);
}

.text-muted {
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Cards */
.card {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Grid Layouts */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

input, select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #f8fafc;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background-color: #ffffff;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #581c87 0%, #7e22ce 100%);
    box-shadow: 0 4px 12px rgba(107, 33, 168, 0.3);
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Navigation */
.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-light);
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

.nav-link:hover {
    background-color: #f3e8ff;
    color: var(--primary);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(107, 33, 168, 0.2);
    font-weight: 600;
}

/* Platform Badges/Indicators */
.platform-card {
    border-top: 4px solid var(--border-color);
}

.platform-card.facebook { border-top-color: var(--facebook); }
.platform-card.tiktok { border-top-color: var(--tiktok); }
.platform-card.shopee { border-top-color: var(--shopee); }
.platform-card.lazada { border-top-color: var(--lazada); }
.platform-card.line-oa { border-top-color: var(--line); }

/* Tables */
.table-container {
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.5);
    margin-top: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background-color: #f8fafc;
    padding: 1rem;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #f8fafc;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* TV Mode Styles */
body.tv-mode-active .sidebar {
    display: none !important;
}

body.tv-mode-active .main-content {
    padding: 1.5rem;
    max-width: 100vw;
}

body.tv-mode-active .grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

body.tv-mode-active h2 {
    font-size: 2.5rem;
}

body.tv-mode-active #history-section {
    display: none !important;
}

body.tv-mode-active .platform-breakdown-grid {
    grid-template-columns: repeat(6, 1fr) !important;
}

body.tv-mode-active .chart-container {
    height: 38vh !important;
    min-height: 250px;
}

/* Premium Gradient Cards */
.bg-gradient-sales {
    background: linear-gradient(135deg, #6b21a8 0%, #9333ea 100%);
    color: white !important;
}
.bg-gradient-ads {
    background: linear-gradient(135deg, #9d174d 0%, #be185d 100%);
    color: white !important;
}
.bg-gradient-orders {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
    color: white !important;
}
.bg-gradient-roi {
    background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
    color: white !important;
}

.bg-gradient-sales h2, .bg-gradient-sales .text-muted, .bg-gradient-sales i,
.bg-gradient-ads h2, .bg-gradient-ads .text-muted, .bg-gradient-ads i,
.bg-gradient-orders h2, .bg-gradient-orders .text-muted, .bg-gradient-orders i,
.bg-gradient-roi h2, .bg-gradient-roi .text-muted, .bg-gradient-roi i {
    color: white !important;
}

.bg-gradient-sales .text-muted,
.bg-gradient-ads .text-muted,
.bg-gradient-orders .text-muted,
.bg-gradient-roi .text-muted {
    opacity: 0.9;
}

.bg-gradient-sales div[style*="background-color"],
.bg-gradient-ads div[style*="background-color"],
.bg-gradient-orders div[style*="background-color"],
.bg-gradient-roi div[style*="background-color"] {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* Platform Cards Enhanced */
.platform-card {
    border-radius: 1rem;
    overflow: hidden;
}

.platform-card.facebook { background: linear-gradient(to right, rgba(24, 119, 242, 0.05), transparent); box-shadow: -4px 0 0 var(--facebook) inset; }
.platform-card.tiktok { background: linear-gradient(to right, rgba(0, 0, 0, 0.05), transparent); box-shadow: -4px 0 0 var(--tiktok) inset; }
.platform-card.shopee { background: linear-gradient(to right, rgba(238, 77, 45, 0.05), transparent); box-shadow: -4px 0 0 var(--shopee) inset; }
.platform-card.lazada { background: linear-gradient(to right, rgba(0, 20, 255, 0.05), transparent); box-shadow: -4px 0 0 var(--lazada) inset; }
.platform-card.line-oa { background: linear-gradient(to right, rgba(0, 185, 0, 0.05), transparent); box-shadow: -4px 0 0 var(--line) inset; }
.platform-card.live { background: linear-gradient(to right, rgba(239, 68, 68, 0.05), transparent); box-shadow: -4px 0 0 var(--live) inset; }

.platform-card:hover {
    box-shadow: var(--shadow-premium), -4px 0 0 var(--primary) inset;
}

/* Wow Card Animation */
.wow-card {
    position: relative;
    padding: 1.25rem !important;
    background-color: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    z-index: 1;
}

.wow-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.95) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-25deg);
    transition: none;
    z-index: 5;
    pointer-events: none;
}

.wow-card:hover {
    transform: translateY(-8px) scale(1.02) !important;
    box-shadow: 0 20px 40px -10px rgba(107, 33, 168, 0.2), 0 0 25px rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(255, 255, 255, 1) !important;
    z-index: 10;
}

.wow-card:hover::before {
    left: 200%;
    transition: left 0.7s ease-in-out;
}

.wow-card i, .wow-card img {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.wow-card:hover h3 {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: all 0.3s;
}

.wow-card:hover i, .wow-card:hover img {
    transform: scale(1.25) rotate(5deg);
}

/* Fallback Logo Styles */
.fallback-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
    color: white !important;
    font-weight: bold;
    font-size: 1.2rem;
    text-transform: uppercase;
}
.fallback-facebook { background-color: var(--facebook); }
.fallback-tiktok { background-color: var(--tiktok); }
.fallback-shopee { background-color: var(--shopee); }
.fallback-lazada { background-color: var(--lazada); }
.fallback-line-oa { background-color: var(--line); }

/* Login Page Specific */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e003a 0%, #4c0570 50%, #1e003a 100%);
    background-size: 200% 200%;
    animation: gradientMove 15s ease infinite;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

/* Glowing Orbs (แสงวิบวับ) */
.login-page::before, .login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    opacity: 0.6;
    animation: floatOrbs 8s infinite alternate ease-in-out;
}

.login-page::before {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #a855f7 0%, transparent 70%);
    top: -100px;
    left: -100px;
}

.login-page::after {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #e879f9 0%, transparent 70%);
    bottom: -150px;
    right: -100px;
    animation-delay: -4s;
    animation-duration: 12s;
}

@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes floatOrbs {
    0% { transform: translateY(0) scale(1); opacity: 0.3; }
    100% { transform: translateY(-50px) scale(1.2); opacity: 0.7; }
}

.login-card {
    position: relative;
    z-index: 1;
    background-color: rgba(255, 255, 255, 0.93);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(168, 85, 247, 0.2);
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-card h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
    color: var(--text-color);
}

.login-card .form-group label {
    color: var(--text-color);
    font-weight: 500;
}

.login-card input {
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
}

.login-card input:focus {
    background-color: #ffffff;
    border-color: var(--primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .grid-4 {
        grid-template-columns: 1fr !important;
    }
    
    .grid-3 {
        grid-template-columns: 1fr !important;
    }
}

.responsive-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .responsive-grid {
        grid-template-columns: 1fr;
    }
}
