/* Global Styles */
:root {
    --primary-color: #58a6ff;
    --primary-glow: rgba(88, 166, 255, 0.4);
    --bg-gradient-start: #0d1117;
    --bg-gradient-mid: #161b22;
    --bg-gradient-end: #0d1117;
    --card-bg: rgba(22, 27, 34, 0.8);
    --card-border: rgba(48, 54, 61, 0.8);
    --card-hover-bg: rgba(88, 166, 255, 0.1);
    --text-color: #e6edf3;
    --heading-font: 'Outfit', 'Segoe UI', sans-serif;
    --body-font: 'Inter', 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 15px 20px 0;
    font-family: var(--body-font);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
    color: var(--primary-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Section */
.header {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
    padding: 10px 0;
    border-bottom: 1px solid var(--card-border);
}

/* Site Title & Logo */
.site-title {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.site-title:hover {
    opacity: 0.8;
}

.site-logo {
    width: 22px;
    height: 22px;
    color: var(--primary-color);
}

h1 {
    margin: 0;
    font-family: var(--heading-font);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--primary-color);
    white-space: nowrap;
}

/* Controls - Center zone (search + sort/filter buttons) */
.controls-center {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

/* Controls - Right zone (edit + settings) */
.controls-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.search-container {
    position: relative;
    min-width: 220px;
}

.search-box {
    width: 100%;
    padding: 8px 35px 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: #fff;
    font-family: var(--body-font);
    font-size: 13px;
    outline: none;
    transition: all 0.15s ease;
}

.search-box::placeholder {
    color: var(--text-color);
    opacity: 0.5;
}

.search-box:focus {
    background: rgba(0, 0, 0, 0.5);
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

.clear-search {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 14px;
    cursor: pointer;
    padding: 2px;
    display: none;
}

.clear-search:hover {
    opacity: 0.7;
}

.clear-search.visible {
    display: block;
}

.control-btn {
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--primary-color);
    font-family: var(--body-font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-btn:hover {
    background: var(--card-hover-bg);
    border-color: var(--primary-color);
}

.control-btn.active {
    background: var(--primary-color);
    color: #051505;
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* Dashboard Grid - Column-first layout */
.dashboard-container {
    column-count: 3;
    column-gap: 10px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding-bottom: 40px;
}

/* Project Cards */
.project-card {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
    gap: 4px;
    break-inside: avoid;
    margin-bottom: 10px;
}

.project-card:hover {
    background: var(--card-hover-bg);
    border-color: var(--primary-color);
}

/* Card Row 1 - RAG, Name, Status */
.card-row1 {
    display: flex;
    align-items: center;
    width: 100%;
}

/* Card Row 2 - Last & Next */
.card-row2 {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 20px;
    min-height: 16px;
}

.card-row2:empty {
    display: none;
}

/* Compact view - hide Last/Next row */
body.compact-view .card-row2 {
    display: none;
}

.meta-text {
    font-size: 10px;
    color: var(--text-color);
    opacity: 0.6;
}

.meta-label {
    font-size: 10px;
    color: var(--text-color);
    opacity: 0.7;
}

.meta-sep {
    font-size: 10px;
    color: var(--text-color);
    opacity: 0.4;
    margin: 0 4px;
}

.meta-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 3px;
    color: var(--text-color);
    font-size: 10px;
    padding: 2px 5px;
    outline: none;
}

.meta-input:focus {
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.5);
}

.meta-input.last-input {
    width: 75px;
}

.meta-input.next-input {
    flex: 1;
    min-width: 80px;
}

/* RAG LED */
.card-row1 .rag-led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.rag-led.grey {
    background: #666;
    box-shadow: 0 0 4px #444;
}

.rag-led.red {
    background: #ff4444;
    box-shadow: 0 0 8px #ff4444, 0 0 12px #ff4444;
}

.rag-led.orange {
    background: #ff9933;
    box-shadow: 0 0 8px #ff9933, 0 0 12px #ff9933;
}

.rag-led.yellow {
    background: #ffdd00;
    box-shadow: 0 0 8px #ffdd00, 0 0 12px #ffdd00;
}

.rag-led.green {
    background: #44ff44;
    box-shadow: 0 0 8px #44ff44, 0 0 12px #44ff44;
}

.rag-led.blue {
    background: #4488ff;
    box-shadow: 0 0 8px #4488ff, 0 0 12px #4488ff;
}

.rag-led.purple {
    background: #aa44ff;
    box-shadow: 0 0 8px #aa44ff, 0 0 12px #aa44ff;
}

.rag-led.brown {
    background: #996633;
    box-shadow: 0 0 6px #996633;
}

body.edit-mode .rag-led {
    cursor: pointer;
}

body.edit-mode .rag-led:hover {
    transform: scale(1.3);
}

.rag-led.emoji-mode {
    background: none !important;
    box-shadow: none !important;
    width: auto;
    height: auto;
    font-size: 16px;
    line-height: 1;
    margin-right: 5px;
    transform: scale(1.2);
}

/* RAG Tooltip */
.rag-tooltip {
    position: absolute;
    background: var(--bg-gradient-mid);
    border: 1px solid var(--primary-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border-radius: 8px;
    padding: 8px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}

.rag-tooltip-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.rag-option {
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rag-option:hover {
    transform: scale(1.2);
}

.rag-option.color-opt {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

/* Re-use existing color classes for the tooltip options */
.rag-option.grey { background: #666; box-shadow: 0 0 4px #444; }
.rag-option.red { background: #ff4444; box-shadow: 0 0 8px #ff4444; }
.rag-option.orange { background: #ff9933; box-shadow: 0 0 8px #ff9933; }
.rag-option.yellow { background: #ffdd00; box-shadow: 0 0 8px #ffdd00; }
.rag-option.green { background: #44ff44; box-shadow: 0 0 8px #44ff44; }
.rag-option.blue { background: #4488ff; box-shadow: 0 0 8px #4488ff; }
.rag-option.purple { background: #aa44ff; box-shadow: 0 0 8px #aa44ff; }
.rag-option.brown { background: #996633; box-shadow: 0 0 6px #996633; }

.rag-option.emoji-opt {
    font-size: 18px;
    width: 24px;
    height: 24px;
}

/* Tags Container */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-left: 8px;
    align-items: center;
}

.tag {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    font-weight: 500;
}

.tag-skillset {
    background: rgba(88, 166, 255, 0.2);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.tag-owner {
    background: rgba(111, 221, 129, 0.2);
    color: #6fdd81;
    border: 1px solid rgba(111, 221, 129, 0.3);
}

.tag-other {
    background: rgba(255, 159, 67, 0.2);
    color: #ff9f43;
    border: 1px solid rgba(255, 159, 67, 0.3);
}

body.edit-mode .tag {
    cursor: pointer;
}

body.edit-mode .tag:hover {
    opacity: 0.7;
}

.tag-add-btn {
    font-size: 11px;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed var(--card-border);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tag-add-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Tag Tooltip */
.tag-tooltip {
    min-width: 280px;
    max-width: 350px;
}

.tag-tooltip-header {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-color);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.tag-tooltip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.tag-option {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tag-option.tag-skillset {
    background: rgba(88, 166, 255, 0.15);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.tag-option.tag-owner {
    background: rgba(111, 221, 129, 0.15);
    color: #6fdd81;
    border: 1px solid rgba(111, 221, 129, 0.3);
}

.tag-option:hover {
    transform: scale(1.05);
}

.tag-option.tag-selected {
    box-shadow: 0 0 6px currentColor;
    font-weight: 600;
}

.tag-option.tag-selected.tag-skillset {
    background: rgba(88, 166, 255, 0.4);
}

.tag-option.tag-selected.tag-owner {
    background: rgba(111, 221, 129, 0.4);
}

.card-row1 .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 80px;
}

.card-row1 .status {
    margin-left: 10px;
    color: var(--primary-color);
    font-size: 11px;
    opacity: 0.7;
    flex-shrink: 0;
}

/* Edit Mode */
body.edit-mode .project-card {
    cursor: default;
    border-color: var(--primary-color);
}

body.edit-mode .project-card:hover {
    transform: none;
}

body.edit-mode .card-row1 .status {
    display: none;
}

body.edit-mode .card-row1 .status-input {
    display: block;
}

.card-row1 .status-input {
    display: none;
    width: 45px;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    color: var(--primary-color);
    font-size: 11px;
    text-align: right;
    margin-left: 10px;
    flex-shrink: 0;
}

.card-row1 .status-input:focus {
    outline: none;
    background: rgba(0, 0, 0, 0.5);
}

/* Hide number input spinners */
.card-row1 .status-input::-webkit-outer-spin-button,
.card-row1 .status-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.card-row1 .status-input {
    -moz-appearance: textfield;
}

#editModeBtn.active {
    background: var(--primary-color);
    color: var(--bg-gradient-mid);
}

/* Helper Classes */
.hidden {
    display: none !important;
}

.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-color);
    opacity: 0.6;
    font-style: italic;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--card-border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer structure */
.footer {
    margin-top: auto;
    padding: 15px 0;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-color);
    opacity: 0.6;
    font-size: 11px;
    max-width: 1600px;
    width: 100%;
    align-self: center;
}

.footer-links a {
    color: var(--primary-color);
    text-decoration: none;
    margin-right: 15px;
    transition: opacity 0.2s;
}

.footer-links a:hover {
    opacity: 0.7;
}

.footer-info {
    text-align: right;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-gradient-mid);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    width: 300px;
    max-width: 90%;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
}

.modal-close:hover {
    opacity: 0.7;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-color);
}

.form-group select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    color: var(--text-color);
    padding: 8px 10px;
    border-radius: 6px;
    font-family: var(--body-font);
    font-size: 12px;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Emoji Key */
.emoji-key {
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--card-border);
}

.emoji-key label {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.emoji-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.emoji-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-color);
    opacity: 0.85;
}

.emoji-item span {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

/* Theme: Dark Mode (default) */
body, body.theme-dark {
    --primary-color: #58a6ff;
    --primary-glow: rgba(88, 166, 255, 0.4);
    --bg-gradient-start: #0d1117;
    --bg-gradient-mid: #161b22;
    --bg-gradient-end: #0d1117;
    --card-bg: rgba(22, 27, 34, 0.8);
    --card-border: rgba(48, 54, 61, 0.8);
    --card-hover-bg: rgba(88, 166, 255, 0.1);
    --text-color: #e6edf3;
}

/* Theme: Forest Green */
body.theme-forest {
    --primary-color: #6fdd81;
    --primary-glow: rgba(111, 221, 129, 0.4);
    --bg-gradient-start: #1a2f23;
    --bg-gradient-mid: #243c2f;
    --bg-gradient-end: #0d1a12;
    --card-bg: rgba(45, 74, 59, 0.5);
    --card-border: rgba(111, 221, 129, 0.3);
    --card-hover-bg: rgba(111, 221, 129, 0.15);
    --text-color: #f0e6d2;
}

/* Theme: Orange Sunset */
body.theme-sunset {
    --primary-color: #ff9f43;
    --primary-glow: rgba(255, 159, 67, 0.4);
    --bg-gradient-start: #2d1b14;
    --bg-gradient-mid: #42261c;
    --bg-gradient-end: #1a0f0a;
    --card-bg: rgba(87, 49, 35, 0.5);
    --card-border: rgba(255, 159, 67, 0.3);
    --card-hover-bg: rgba(255, 159, 67, 0.15);
    --text-color: #ffe6dd;
}

/* Theme: Antique White */
body.theme-antique {
    --primary-color: #5a4a3a;
    --primary-glow: rgba(90, 74, 58, 0.3);
    --bg-gradient-start: #f5f0e6;
    --bg-gradient-mid: #ebe4d6;
    --bg-gradient-end: #d4cbbf;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(90, 74, 58, 0.3);
    --card-hover-bg: rgba(90, 74, 58, 0.1);
    --text-color: #3a3028;
}

body.theme-antique .project-card {
    color: #3a3028;
}

body.theme-antique .search-box {
    background: rgba(255, 255, 255, 0.5);
    color: #3a3028;
}

body.theme-antique .search-box::placeholder {
    color: rgba(90, 74, 58, 0.5);
}

body.theme-antique .modal {
    background: #ebe4d6;
}

body.theme-antique .form-group select {
    background: rgba(255, 255, 255, 0.5);
    color: #3a3028;
}

body.theme-antique .tag-skillset,
body.theme-antique .tag-option.tag-skillset {
    background: rgba(58, 98, 138, 0.2);
    color: #3a628a;
    border-color: rgba(58, 98, 138, 0.4);
}

body.theme-antique .tag-owner,
body.theme-antique .tag-option.tag-owner {
    background: rgba(74, 118, 78, 0.2);
    color: #4a764e;
    border-color: rgba(74, 118, 78, 0.4);
}

body.theme-antique .tag-add-btn {
    background: rgba(90, 74, 58, 0.1);
    border-color: rgba(90, 74, 58, 0.3);
    color: #5a4a3a;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .dashboard-container {
        column-count: 2;
    }
}

/* Responsive - Mobile */
@media (max-width: 600px) {
    body {
        padding: 15px 15px 0;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 20px;
    }

    .controls-center {
        flex-wrap: wrap;
        width: 100%;
        order: 3;
    }

    .controls-right {
        order: 2;
    }

    .search-container {
        min-width: 100%;
    }

    .dashboard-container {
        column-count: 1;
    }

    .footer {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .footer-info {
        text-align: center;
    }
}