/*
 * Partix Theme Base - Shared styles for all themes
 * Uses CSS Custom Properties for theme-specific colors
 */

/* ==========================================
   Base CSS Variables (Default/Fallback)
   ========================================== */
:root {
    /* Primary accent color - overridden by theme */
    --primary: var(--primary-color, #dc2626);
    --primary-dark: var(--primary-color-dark, #b91c1c);
    --primary-light: var(--primary-color-light, #ff4444);
    --primary-rgb: var(--primary-color-rgb, 220, 38, 38);

    /* Background Colors - shared across all themes */
    --bg-dark: #0a0a0a;
    --bg-darker: #1a1a1a;
    --bg-glass: rgba(26, 26, 26, 0.95);
    --bg-glass-light: rgba(30, 30, 30, 0.8);

    /* Text Colors - shared */
    --text-white: #ffffff;
    --text-gray: #f8fafc;
    --text-light-gray: #ffffff;

    /* Border and Glass Effects - shared */
    --border-gray: #374151;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-border-accent: rgba(var(--primary-rgb), 0.3);

    /* Shadows and Effects */
    --shadow-dark: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 20px rgba(var(--primary-rgb), 0.3);
    --shadow-accent: 0 4px 20px rgba(var(--primary-rgb), 0.4);

    /* Gradients */
    --gradient-accent: linear-gradient(135deg, var(--primary), var(--primary-dark));
    --gradient-bg: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
}

/* ==========================================
   Theme Color Overrides
   ========================================== */

/* Insights Theme - Red */
:root[data-theme="insights"],
html[data-theme="insights"] {
    --primary-color: #dc2626;
    --primary-color-dark: #b91c1c;
    --primary-color-light: #ff4444;
    --primary-color-rgb: 220, 38, 38;
}

/* Actions Theme - Green */
:root[data-theme="actions"],
html[data-theme="actions"] {
    --primary-color: #166534;
    --primary-color-dark: #14532d;
    --primary-color-light: #16a34a;
    --primary-color-rgb: 22, 101, 52;
}

/* Connect Theme - Blue */
:root[data-theme="connect"],
html[data-theme="connect"] {
    --primary-color: #1e40af;
    --primary-color-dark: #1e3a8a;
    --primary-color-light: #3b82f6;
    --primary-color-rgb: 30, 64, 175;
}

/* ==========================================
   Base Body Styling
   ========================================== */
body[class*="theme-"] {
    background: var(--gradient-bg);
    color: var(--text-white);
    position: relative;
    overflow-x: hidden;
}

/* Animated background */
body[class*="theme-"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(var(--primary-rgb), 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(var(--primary-rgb), 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(var(--primary-rgb), 0.05) 0%, transparent 50%);
    animation: backgroundShift 20s ease-in-out infinite;
    z-index: -2;
    pointer-events: none;
}

/* ==========================================
   Floating Particles
   ========================================== */
.particle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    animation: float 15s infinite linear;
    z-index: -1;
    pointer-events: none;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 20s; }
.particle:nth-child(2) { left: 20%; animation-delay: 2s; animation-duration: 25s; }
.particle:nth-child(3) { left: 30%; animation-delay: 4s; animation-duration: 18s; }
.particle:nth-child(4) { left: 40%; animation-delay: 6s; animation-duration: 22s; }
.particle:nth-child(5) { left: 50%; animation-delay: 8s; animation-duration: 16s; }
.particle:nth-child(6) { left: 60%; animation-delay: 10s; animation-duration: 24s; }
.particle:nth-child(7) { left: 70%; animation-delay: 12s; animation-duration: 19s; }
.particle:nth-child(8) { left: 80%; animation-delay: 14s; animation-duration: 21s; }
.particle:nth-child(9) { left: 90%; animation-delay: 16s; animation-duration: 17s; }
.particle:nth-child(10) { left: 95%; animation-delay: 18s; animation-duration: 23s; }

/* ==========================================
   Animations
   ========================================== */
@keyframes backgroundShift {
    0%, 100% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(-2%) translateY(-1%); }
    50% { transform: translateX(1%) translateY(-2%); }
    75% { transform: translateX(-1%) translateY(1%); }
}

@keyframes float {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100px) rotate(360deg); opacity: 0; }
}

@keyframes pulseAccent {
    0%, 100% {
        box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.3), 0 0 40px rgba(var(--primary-rgb), 0.1);
    }
    50% {
        box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.6), 0 0 60px rgba(var(--primary-rgb), 0.2);
    }
}

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

/* ==========================================
   Navbar Styling
   ========================================== */
body[class*="theme-"] .navbar {
    background: var(--gradient-bg) !important;
    border-bottom: 2px solid var(--glass-border-accent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

body[class*="theme-"] .navbar-brand {
    color: var(--text-white) !important;
    font-weight: 700;
    text-shadow: 0 0 20px rgba(var(--primary-rgb), 0.5);
}

body[class*="theme-"] .navbar-brand i {
    color: var(--primary-light) !important;
}

body[class*="theme-"] .navbar .nav-link {
    color: var(--text-white) !important;
    transition: all 0.3s ease;
}

body[class*="theme-"] .navbar .nav-link:hover {
    color: var(--primary-light) !important;
    text-shadow: 0 0 10px rgba(var(--primary-rgb), 0.5);
}

/* ==========================================
   Platform Switcher Buttons
   ========================================== */
body[class*="theme-"] .platform-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-white);
    transition: all 0.3s ease;
}

body[class*="theme-"] .platform-btn:hover {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
}

body[class*="theme-"] .platform-btn.active {
    background: var(--gradient-accent);
    border-color: var(--primary);
    box-shadow: var(--shadow-accent);
}

/* ==========================================
   Cards and Widgets
   ========================================== */
body[class*="theme-"] .card {
    background: var(--bg-glass) !important;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-dark);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

body[class*="theme-"] .card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light), var(--primary));
    background-size: 200% 100%;
    animation: gradientShift 3s ease-in-out infinite;
}

body[class*="theme-"] .card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-accent);
    transform: translateY(-2px);
}

body[class*="theme-"] .card-header {
    background: rgba(30, 30, 30, 0.9) !important;
    color: var(--text-white) !important;
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.2);
    border-radius: 16px 16px 0 0 !important;
}

body[class*="theme-"] .widget-card {
    background: var(--bg-glass) !important;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.1);
    transition: all 0.3s ease;
}

body[class*="theme-"] .widget-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-accent);
    transform: translateY(-2px);
}

/* ==========================================
   Buttons
   ========================================== */
body[class*="theme-"] .btn-primary {
    background: var(--gradient-accent);
    border: none;
    color: var(--text-white) !important;
    font-weight: 600;
    border-radius: 12px;
    padding: 12px 24px;
    box-shadow: var(--shadow-accent);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

body[class*="theme-"] .btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s;
}

body[class*="theme-"] .btn-primary:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 30px rgba(var(--primary-rgb), 0.6), 0 0 25px rgba(var(--primary-rgb), 0.4);
}

body[class*="theme-"] .btn-primary:hover::before {
    left: 100%;
}

body[class*="theme-"] .btn-outline-primary {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary) !important;
}

body[class*="theme-"] .btn-outline-primary:hover {
    background: var(--primary);
    color: var(--text-white) !important;
    box-shadow: var(--shadow-accent);
}

/* ==========================================
   Form Elements
   ========================================== */
body[class*="theme-"] .form-control,
body[class*="theme-"] .form-select {
    background: rgba(30, 30, 30, 0.8) !important;
    border: 2px solid rgba(var(--primary-rgb), 0.2);
    color: var(--text-white) !important;
    border-radius: 12px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body[class*="theme-"] .form-control:focus,
body[class*="theme-"] .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.2), 0 0 20px rgba(var(--primary-rgb), 0.1);
    background: rgba(30, 30, 30, 0.9) !important;
    transform: translateY(-2px);
}

body[class*="theme-"] .form-control::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* ==========================================
   Modals
   ========================================== */
body[class*="theme-"] .modal-content {
    background: var(--bg-glass) !important;
    border: 1px solid var(--glass-border-accent);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

body[class*="theme-"] .modal-header {
    background: var(--gradient-accent) !important;
    color: var(--text-white) !important;
    border-bottom: 1px solid var(--glass-border);
    border-radius: 16px 16px 0 0;
}

body[class*="theme-"] .modal-body {
    background: transparent !important;
    color: var(--text-white) !important;
}

body[class*="theme-"] .modal-footer {
    background: transparent !important;
    border-top: 1px solid var(--glass-border) !important;
}

body[class*="theme-"] .modal-body label,
body[class*="theme-"] .modal-body .form-label,
body[class*="theme-"] .modal-body .form-check-label {
    color: var(--text-white) !important;
}

body[class*="theme-"] .modal-body .text-muted {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* ==========================================
   Dropdowns
   ========================================== */
body[class*="theme-"] .dropdown-menu {
    background: var(--bg-darker) !important;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--shadow-dark);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

body[class*="theme-"] .dropdown-item {
    color: var(--text-white) !important;
    transition: all 0.3s ease;
}

body[class*="theme-"] .dropdown-item:hover {
    background: rgba(var(--primary-rgb), 0.1) !important;
    color: var(--primary-light) !important;
    transform: translateX(4px);
}

/* ==========================================
   Alerts
   ========================================== */
body[class*="theme-"] .alert {
    background: rgba(var(--primary-rgb), 0.1) !important;
    border: 1px solid var(--primary);
    border-radius: 12px;
    color: var(--text-white) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* ==========================================
   Scrollbar
   ========================================== */
body[class*="theme-"] ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

body[class*="theme-"] ::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
}

body[class*="theme-"] ::-webkit-scrollbar-thumb {
    background: var(--gradient-accent);
    border-radius: 5px;
    border: 2px solid transparent;
}

body[class*="theme-"] ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.5);
}

/* ==========================================
   Badges
   ========================================== */
body[class*="theme-"] .badge {
    font-weight: 600;
    padding: 0.4em 0.8em;
    border-radius: 8px;
    background: rgba(var(--primary-rgb), 0.2);
    border: 1px solid var(--primary);
    color: var(--primary-light) !important;
}

body[class*="theme-"] .badge.bg-primary {
    background: var(--gradient-accent) !important;
    color: var(--text-white) !important;
    border: none;
}

/* ==========================================
   Spinners
   ========================================== */
body[class*="theme-"] .spinner-border {
    border-color: var(--primary);
    border-right-color: transparent;
}

/* ==========================================
   List Groups
   ========================================== */
body[class*="theme-"] .list-group-item {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid var(--glass-border);
    color: var(--text-white) !important;
    transition: all 0.3s ease;
}

body[class*="theme-"] .list-group-item:hover {
    background: rgba(var(--primary-rgb), 0.05) !important;
    border-color: var(--primary);
    transform: translateX(4px);
}

body[class*="theme-"] .list-group-item.active {
    background: var(--gradient-accent) !important;
    border-color: var(--primary);
    color: var(--text-white) !important;
}

/* ==========================================
   Tables
   ========================================== */
body[class*="theme-"] .table {
    color: var(--text-white);
}

body[class*="theme-"] .table thead th {
    background: rgba(var(--primary-rgb), 0.1);
    border-bottom: 2px solid var(--primary);
}

body[class*="theme-"] .table tbody tr {
    border-bottom: 1px solid var(--glass-border);
}

body[class*="theme-"] .table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

/* ==========================================
   Navigation Tabs
   ========================================== */
body[class*="theme-"] .nav-tabs {
    border-bottom: 2px solid var(--glass-border);
}

body[class*="theme-"] .nav-tabs .nav-link {
    color: var(--text-gray) !important;
    border: none;
    padding: 12px 20px;
    transition: all 0.3s ease;
}

body[class*="theme-"] .nav-tabs .nav-link:hover {
    color: var(--primary-light) !important;
    background: rgba(var(--primary-rgb), 0.1);
}

body[class*="theme-"] .nav-tabs .nav-link.active {
    color: var(--primary-light) !important;
    background: transparent;
    border-bottom: 2px solid var(--primary);
}

/* ==========================================
   Utility Classes
   ========================================== */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

.accent-glow {
    box-shadow: var(--shadow-glow);
}

.accent-border {
    border-color: var(--primary) !important;
}

.text-accent {
    color: var(--primary) !important;
}

.bg-accent {
    background: var(--gradient-accent) !important;
}

/* ==========================================
   Permission-based visibility
   ========================================== */
.requires-edit-permission,
.requires-delete-permission,
.requires-admin-permission {
    /* Default visible, hide via JS when user lacks permission */
}

[data-permission-hidden="true"] {
    display: none !important;
}

/* ==========================================
   Responsive Utilities
   ========================================== */
@media (max-width: 768px) {
    body[class*="theme-"] .card {
        border-radius: 12px;
    }

    body[class*="theme-"] .btn-primary,
    body[class*="theme-"] .btn-outline-primary {
        padding: 10px 16px;
        min-height: 44px;
    }

    .touch-target {
        min-height: 48px;
        min-width: 48px;
    }
}

