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

:root {
    /* RBIH Color Palette */
    --indivara: hsl(262, 72%, 23%);
    --terracotta: hsl(12, 44%, 52%);
    --turmeric: hsl(38, 81%, 57%);
    --neem: hsl(80, 60%, 35%);
    --charcoal: hsl(0, 0%, 18%);
    --ivory: hsl(50, 32%, 93%);
    --sand: hsl(41, 38%, 81%);
    --vermilion: hsl(6, 72%, 54%);
}

/* Light Theme (default) */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-input: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --accent: var(--terracotta);
    --accent-hover: hsl(12, 44%, 45%);
    --success: #22c55e;
    --success-bg: #dcfce7;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #1e293b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --accent: var(--terracotta);
    --accent-hover: hsl(12, 44%, 60%);
    --success: #4ade80;
    --success-bg: rgba(34, 197, 94, 0.2);
    --warning: #fbbf24;
    --warning-bg: rgba(245, 158, 11, 0.2);
    --danger: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.2);
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar.collapsed {
    display: none;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    height: 32px;
    width: auto;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.collapse-btn {
    position: absolute;
    right: -12px;
    top: 80px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.collapse-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.sidebar-content {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 16px;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Stats Compact */
.stats-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.stats-compact.hidden {
    display: none;
}

.stat-item {
    background: var(--bg-hover);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    transition: background-color 0.2s ease;
}

.stat-item:hover {
    background: var(--border-color);
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-item.deployed .stat-number {
    color: var(--success);
}

.stat-item.behind .stat-number {
    color: var(--warning);
}

.stat-item.not-deployed .stat-number {
    color: var(--danger);
}

/* Filter Items */
.filter-item {
    margin-bottom: 12px;
}

.filter-item.half {
    margin-bottom: 0;
}

.filter-item label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.filter-item input,
.filter-item select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-item input:focus,
.filter-item select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(183, 111, 87, 0.15);
}

/* Filter Rows - Two items per row */
.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.search-wrapper {
    position: relative;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-wrapper input {
    padding-left: 38px;
}

/* Filter Select Button */
.filter-select-btn {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s ease;
}

.filter-select-btn:hover {
    border-color: var(--accent);
}

/* Dropdown */
.dropdown-content {
    display: none;
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 250px;
    overflow-y: auto;
    width: calc(100% - 32px);
    margin-top: 4px;
}

.dropdown-content.show {
    display: block;
}

.dropdown-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-hover);
}

.dropdown-list {
    padding: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.checkbox-label:hover {
    background: var(--bg-hover);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* Buttons */
.clear-btn {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.export-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.export-btn {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

/* When sidebar is collapsed */
.sidebar.collapsed + .main-content {
    margin-left: 0;
}

.sidebar.collapsed + .main-content .menu-toggle {
    display: flex;
}

/* Top Bar */
.top-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    align-items: center;
    justify-content: center;
}

.menu-toggle:hover {
    background: var(--bg-hover);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    background: none;
    -webkit-text-fill-color: var(--text-primary);
}

.top-bar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-updated {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.icon-btn {
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.icon-btn.loading svg {
    animation: spin 1s linear infinite;
}

/* Theme Toggle */
.theme-toggle .sun-icon {
    display: block;
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Error Message */
.error-message {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Releases Grid */
.releases-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Platform Release Group */
.platform-release-group {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.platform-release-header {
    padding: 16px 20px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.platform-version {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

.release-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: 20px;
}

.platform-releases {
    padding: 16px;
    display: grid;
    gap: 12px;
}

/* Issue Card */
.issue-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--warning);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s ease;
}

.issue-card:hover {
    box-shadow: var(--shadow-lg);
    border-left-color: var(--accent);
}

.issue-card.deployed {
    border-left-color: var(--success);
}

.issue-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.issue-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.service-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.deployment-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--success-bg);
    color: var(--success);
    font-weight: 500;
}

.issue-metadata {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.issue-number {
    font-size: 0.8rem;
    padding: 2px 8px;
    background: var(--bg-hover);
    border-radius: 4px;
    color: var(--text-secondary);
    font-weight: 500;
}

.issue-title-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.release-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.detail-value {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.detail-value a {
    color: var(--accent);
    text-decoration: none;
}

.detail-value a:hover {
    text-decoration: underline;
}

/* Issue Labels */
.issue-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.env-label {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 4px;
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-secondary);
}

.release-label {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 4px;
    background: rgba(183, 111, 87, 0.15);
    color: var(--accent);
}

/* Deployment Result */
.deployment-result {
    font-size: 0.8rem;
    padding: 10px 12px;
    background: var(--success-bg);
    border-radius: 6px;
    color: var(--success);
}

.deployment-result a {
    color: inherit;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .content-area {
        padding: 16px;
    }
}

@media (max-width: 640px) {
    .top-bar {
        padding: 12px 16px;
    }

    .page-title {
        font-size: 1rem;
    }

    .last-updated {
        display: none;
    }

    .release-details {
        grid-template-columns: 1fr 1fr;
    }

    .platform-release-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.show {
    display: block;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection styling */
::selection {
    background: rgba(183, 111, 87, 0.3);
}
