/* 
 * Niche Finder AI Premium Light Theme Stylesheet
 * Sleek, modern, and high-performance SaaS dashboard aesthetics.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* Design Tokens / Variables */
:root {
    --bg-main: #f8fafc; /* light slate background */
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #f8fafc 100%);
    
    --card-bg: #ffffff; /* pure white cards */
    --card-bg-hover: #fcfcfd;
    --card-border: #e2e8f0; /* light slate border */
    --card-border-focus: #a78bfa;
    
    --accent-purple: #7c3aed;
    --accent-purple-hover: #6d28d9;
    --accent-purple-glow: rgba(124, 58, 237, 0.12);
    
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.1);
    
    --accent-cyan: #0284c7; /* high-contrast cyan/sky-blue */
    --accent-orange: #ea580c; /* high-contrast orange */
    
    --text-primary: #0f172a; /* dark slate */
    --text-muted: #475569; /* slate grey */
    --text-dark: #94a3b8; /* light slate grey */
    
    --sidebar-width: 260px;
    --transition-speed: 0.2s;
}

/* Reset & Core Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-main);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Panel Card Utility */
.glass-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    transition: all var(--transition-speed) ease;
}

.glass-panel:hover {
    border-color: #cbd5e1;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

/* Layout Grid Structure */
.admin-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 40px;
    width: 100%;
    margin-top: 70px; /* space for the fixed header */
    transition: all var(--transition-speed) ease;
}

/* Top Header Styling */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    z-index: 1000;
    display: flex;
    align-items: center;
    border-radius: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -2px rgba(0, 0, 0, 0.02);
}

.header-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-nav .nav-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-speed) ease;
    border: 1px solid transparent;
}

.header-nav .nav-item:hover {
    color: var(--text-primary);
    background: #f1f5f9;
}

.header-nav .nav-item.active {
    color: var(--accent-purple);
    background: #f5f3ff;
    border-color: #ede9fe;
    font-weight: 600;
}

/* Profile Dropdown Container */
.profile-dropdown-container {
    position: relative;
}

.admin-avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f5f3ff;
    border: 1px solid #ede9fe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--accent-purple);
    font-size: 1rem;
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.05);
    transition: all 0.2s ease;
}

.profile-trigger-btn:hover .admin-avatar-circle {
    border-color: #c084fc;
    box-shadow: 0 4px 8px rgba(124, 58, 237, 0.1);
}

.profile-dropdown-menu {
    position: absolute;
    top: 50px;
    right: 0;
    width: 220px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    display: none;
    flex-direction: column;
    padding: 8px;
    z-index: 1100;
}

.profile-dropdown-menu.show {
    display: flex;
    animation: fadeInDropdown 0.2s ease-out;
}

@keyframes fadeInDropdown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
    padding: 12px;
}

.admin-dropdown-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.admin-dropdown-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dropdown-divider {
    border: 0;
    border-top: 1px solid var(--card-border);
    margin: 4px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.dropdown-item:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.dropdown-item.text-danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Modal Styling */
.profile-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.profile-modal-overlay.show {
    display: flex;
}

.profile-modal-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    width: 90%;
    max-width: 460px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: modalScaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.profile-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--card-border);
}

.profile-modal-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s ease;
    padding: 0;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.profile-modal-body {
    padding: 24px;
}

/* Header Dashboard controls */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* Stat Card Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    border-radius: 12px;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-purple);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.stat-card.emerald::before { background: var(--accent-emerald); }
.stat-card.cyan::before { background: #0284c7; }
.stat-card.orange::before { background: var(--accent-orange); }

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: #f5f3ff;
    color: var(--accent-purple);
    border: 1px solid #ede9fe;
}

.stat-card.emerald .stat-icon {
    background: #ecfdf5;
    color: var(--accent-emerald);
    border-color: #d1fae5;
}
.stat-card.cyan .stat-icon {
    background: #f0f9ff;
    color: #0284c7;
    border-color: #e0f2fe;
}
.stat-card.orange .stat-icon {
    background: #fff7ed;
    color: var(--accent-orange);
    border-color: #ffedd5;
}

/* Secondary Panels Layout */
.dashboard-details {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
}

@media (max-width: 1024px) {
    .dashboard-details {
        grid-template-columns: 1fr;
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--card-border);
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Tables Styling */
.table-container {
    overflow-x: auto;
    width: 100%;
}

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

.custom-table th {
    padding: 16px 24px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f8fafc;
    border-bottom: 1px solid var(--card-border);
}

.custom-table td {
    padding: 16px 24px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-primary);
}

.custom-table tbody tr {
    transition: background-color var(--transition-speed) ease;
}

.custom-table tbody tr:hover {
    background-color: #f8fafc;
}

.custom-table tbody tr:last-child td {
    border-bottom: none;
}

/* Expandable row styling */
.keyword-row {
    cursor: pointer;
}

.keyword-row:hover td {
    color: var(--accent-purple);
}

.details-row {
    background: #f8fafc !important;
}

.details-cell {
    padding: 0 !important;
    border-bottom: 1px solid #ddd6fe !important;
}

.competitor-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1);
    padding: 0 24px;
}

.competitor-accordion-content.open {
    max-height: 2000px;
    padding: 20px 24px;
    transition: max-height 0.4s ease-in-out;
}

/* Inner Competitor Table */
.competitor-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 10px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.competitor-table th {
    padding: 12px 16px;
    font-size: 0.75rem;
    background: #f1f5f9;
    color: var(--text-muted);
    border-bottom: 1px solid #e2e8f0;
}

.competitor-table td {
    padding: 12px 16px;
    font-size: 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
}

.competitor-table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-info {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.badge-warning {
    background: #ffedd5;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.badge-outline {
    background: #f8fafc;
    color: var(--text-muted);
    border: 1px solid #e2e8f0;
}

.badge-best {
    background: linear-gradient(135deg, #f3e8ff, #e0f2fe);
    color: #6b21a8;
    border: 1px solid #d8b4fe;
}

/* Country Progress list */
.country-list {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.country-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.country-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
}

.country-name {
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.country-count {
    color: var(--text-muted);
}

.progress-bar-bg {
    height: 6px;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
    width: 100%;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(to right, var(--accent-purple), #3b82f6);
    width: 0;
    transition: width 1s ease-in-out;
}

/* Forms controls styling */
.filter-form-panel {
    padding: 24px;
    margin-bottom: 30px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-input {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-speed) ease;
    outline: none;
    width: 100%;
}

.form-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px var(--accent-purple-glow);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
    padding: 12px 0;
    color: var(--text-muted);
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    transition: all var(--transition-speed) ease;
}

input[type="checkbox"] {
    display: none;
}

input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
}

input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.75rem;
    color: white;
}

/* Buttons Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border: 1px solid transparent;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-purple);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-purple-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-muted);
    border-color: #cbd5e1;
}

.btn-secondary:hover {
    background: #f8fafc;
    color: var(--text-primary);
    border-color: #94a3b8;
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.btn-danger:hover {
    background: #fecaca;
}

/* Admin Auth login style */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo-icon {
    margin: 0 auto 16px auto;
}

.login-title {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

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

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}

.alert-danger {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* Empty data state style */
.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 16px;
    color: var(--accent-purple);
    opacity: 0.5;
}

/* Pagination Styling */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: #ffffff;
    border-top: 1px solid var(--card-border);
}

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

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    border: 1px solid #cbd5e1;
    background: #ffffff;
    transition: all var(--transition-speed) ease;
}

.pagination-btn:hover:not(.disabled) {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    background: #f5f3ff;
}

.pagination-btn.active {
    background: var(--accent-purple);
    color: white;
    border-color: var(--accent-purple);
    font-weight: 600;
}

.pagination-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
}

/* Helper utilities */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-4 { margin-top: 1.5rem; }
.mr-2 { margin-right: 0.5rem; }
.flex-row { display: flex; align-items: center; gap: 8px; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .header-container {
        padding: 0 20px;
    }
    
    .main-content {
        padding: 20px;
        margin-top: 70px;
    }
    
    .header-nav .nav-item span {
        display: none;
    }
    
    .header-logo .logo-text {
        font-size: 1rem;
    }
}
