/**
 * SituBoard Theme System
 *
 * Provides two modern themes via CSS custom properties:
 * - Dark Modern (default): Deep dark backgrounds with blue accents
 * - Light Modern: Clean light backgrounds with blue accents
 *
 * Theme is stored in localStorage and applied via data-theme attribute on <html>
 *
 * Shape language: sharp professional corners (2px hair radius) — not Bootstrap pills.
 * Board content themes (ship/port grids) keep their own rules in main.css / port.css.
 */

/* ============================================
   DARK MODERN THEME (Default)
   ============================================ */
:root,
:root[data-theme="dark-modern"] {
    /* Background Colors */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-input: #0d1117;

    /* Border Colors */
    --border-primary: #30363d;
    --border-secondary: #21262d;
    --border-accent: #5c7a96;

    /* Accent Colors */
    --accent-primary: #9eb6ce;
    --accent-secondary: #3fb950;
    --accent-warning: #d29922;
    --accent-danger: #f85149;
    --accent-info: #9eb6ce;

    /* Text Colors */
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-inverse: #0d1117;

    /* Status Colors (consistent across themes) */
    --status-red: #ef5350;
    --status-green: #4caf50;
    --status-amber: #ff9800;
    --status-yellow: #ffeb3b;
    --status-blue: #2196f3;
    --status-light-blue: #03a9f4;
    --status-brown: #795548;
    --status-grey: #9e9e9e;
    --status-black: #212121;
    --status-greenblue: #00e676;

    /* Component Specific */
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    --modal-bg: #161b22;
    --header-bg: #010409;
    --footer-bg: #010409;

    /* Table Specific */
    --table-header-bg: #161b22;
    --table-row-hover: rgba(139, 163, 188, 0.08);
    --table-border: #30363d;

    /* Button Colors */
    --btn-primary-bg: #8ba3bc;
    --btn-primary-text: #0d1117;
    --btn-secondary-bg: #21262d;
    --btn-secondary-text: #f0f6fc;
    --btn-danger-bg: #f85149;
    --btn-danger-text: #ffffff;

    /* Shape — hair radius (professional, not Bootstrap-rounded) */
    --radius: 2px;
    --radius-sm: 2px;
    --radius-md: 2px;
    --radius-lg: 2px;
    --radius-pill: 2px; /* chips stay square-ish; use 50% only for true circles */
    --radius-circle: 50%;
    --focus-ring: 0 0 0 3px rgba(139, 163, 188, 0.22);
}

/* ============================================
   LIGHT MODERN THEME
   ============================================ */
:root[data-theme="light-modern"] {
    /* Background Colors */
    --bg-primary: #f6f8fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eaeef2;
    --bg-input: #ffffff;

    /* Border Colors */
    --border-primary: #d0d7de;
    --border-secondary: #eaeef2;
    --border-accent: #0b3d5c;

    /* Accent Colors */
    --accent-primary: #0b3d5c;
    --accent-secondary: #1a7f37;
    --accent-warning: #9a6700;
    --accent-danger: #cf222e;
    --accent-info: #0b3d5c;

    /* Text Colors */
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8c959f;
    --text-inverse: #ffffff;

    /* Status Colors (consistent across themes) */
    --status-red: #ef5350;
    --status-green: #4caf50;
    --status-amber: #ff9800;
    --status-yellow: #ffeb3b;
    --status-blue: #2196f3;
    --status-light-blue: #03a9f4;
    --status-brown: #795548;
    --status-grey: #9e9e9e;
    --status-black: #212121;
    --status-greenblue: #00c853;

    /* Component Specific */
    --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    --modal-bg: #ffffff;
    --header-bg: #ffffff;
    --footer-bg: #f6f8fa;

    /* Table Specific */
    --table-header-bg: #f6f8fa;
    --table-row-hover: rgba(11, 61, 92, 0.06);
    --table-border: #d0d7de;

    /* Button Colors */
    --btn-primary-bg: #0b1f33;
    --btn-primary-text: #ffffff;
    --btn-secondary-bg: #eaeef2;
    --btn-secondary-text: #1f2328;
    --btn-danger-bg: #cf222e;
    --btn-danger-text: #ffffff;

    --focus-ring: 0 0 0 3px rgba(11, 61, 92, 0.18);
}

/* ============================================
   BOOTSTRAP 4 NEUTRALIZATION
   Keep Bootstrap JS/grid; remove stock rounded look.
   ============================================ */
.btn,
.btn-sm,
.btn-lg,
.btn-group > .btn,
.btn-group-sm > .btn,
.btn-group-lg > .btn,
.form-control,
.form-control-sm,
.form-control-lg,
.custom-select,
.custom-select-sm,
.custom-select-lg,
.custom-file-label,
.input-group-text,
.input-group > .form-control,
.input-group > .custom-select,
.input-group > .custom-file,
.dropdown-menu,
.modal-content,
.card,
.alert,
.badge,
.nav-tabs .nav-link,
.nav-pills .nav-link,
.list-group-item,
.popover,
.toast,
.progress,
.custom-control-label::before,
.page-link {
    border-radius: var(--radius) !important;
}

/* Full-width system strips stay flush */
.alert-dismissible .close {
    border-radius: 0;
}

.btn {
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.btn:focus,
.btn.focus,
.form-control:focus,
.custom-select:focus {
    box-shadow: var(--focus-ring) !important;
}

/* Theme-aware Bootstrap primary / secondary / light */
.btn-primary {
    background-color: var(--btn-primary-bg) !important;
    border-color: var(--btn-primary-bg) !important;
    color: var(--btn-primary-text) !important;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active {
    background-color: var(--btn-primary-bg) !important;
    border-color: var(--btn-primary-bg) !important;
    color: var(--btn-primary-text) !important;
    opacity: 0.92;
}

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

.btn-outline-primary {
    color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    background: transparent !important;
}
.btn-outline-primary:hover {
    background: var(--accent-primary) !important;
    color: var(--btn-primary-text) !important;
}

.btn-outline-secondary {
    color: var(--text-secondary) !important;
    border-color: var(--border-primary) !important;
    background: transparent !important;
}
.btn-outline-secondary:hover {
    border-color: var(--accent-primary) !important;
    color: var(--accent-primary) !important;
    background: transparent !important;
}

.btn-outline-danger {
    color: var(--accent-danger) !important;
    border-color: var(--accent-danger) !important;
    background: transparent !important;
}
.btn-outline-danger:hover {
    background: var(--accent-danger) !important;
    color: #fff !important;
}

.btn-danger {
    background-color: var(--btn-danger-bg) !important;
    border-color: var(--btn-danger-bg) !important;
    color: var(--btn-danger-text) !important;
}

.btn-light,
.btn-light:hover,
.btn-light:focus {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
}

.btn-info {
    background-color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    color: var(--btn-primary-text) !important;
}

.btn-warning {
    background-color: var(--accent-warning) !important;
    border-color: var(--accent-warning) !important;
    color: #0d1117 !important;
}

.btn-success {
    background-color: var(--accent-secondary) !important;
    border-color: var(--accent-secondary) !important;
    color: #fff !important;
}

.form-control,
.custom-select {
    background-color: var(--bg-input) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
}
.form-control:focus,
.custom-select:focus {
    background-color: var(--bg-input) !important;
    border-color: var(--accent-primary) !important;
    color: var(--text-primary) !important;
}
.form-control::placeholder {
    color: var(--text-muted) !important;
}

.modal-content {
    background-color: var(--modal-bg) !important;
    border: 1px solid var(--border-primary) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
.modal-header,
.modal-footer {
    border-color: var(--border-primary) !important;
}
.modal-title {
    color: var(--text-primary);
}
.modal-header .close {
    color: var(--text-secondary);
    text-shadow: none;
    opacity: 0.85;
}
.modal-header .close:hover {
    color: var(--text-primary);
    opacity: 1;
}

.card {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary);
}

.dropdown-menu {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary) !important;
    color: var(--text-primary);
    box-shadow: var(--card-shadow);
}
.dropdown-item {
    color: var(--text-primary);
}
.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--table-row-hover) !important;
    color: var(--text-primary);
}

.badge {
    font-weight: 600;
    letter-spacing: 0.4px;
}

.table {
    color: var(--text-primary);
}
.table td,
.table th {
    border-color: var(--table-border) !important;
}
.table thead th {
    border-bottom-color: var(--border-accent) !important;
    color: var(--text-secondary);
}
.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(127, 127, 127, 0.06);
}
.text-muted {
    color: var(--text-muted) !important;
}

.alert {
    border-width: 1px;
}

.nav-tabs {
    border-bottom-color: var(--border-primary);
}
.nav-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.nav-tabs .nav-link:hover {
    border-color: transparent;
    color: var(--text-primary);
}
.nav-tabs .nav-link.active {
    background: transparent;
    color: var(--accent-primary);
    border-color: transparent transparent var(--accent-primary);
}

/* ============================================
   THEME DROPDOWN COMPONENT
   ============================================ */
.theme-selector {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.theme-selector-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.theme-selector-dropdown {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    /* Right padding reserved for chevron — do not override with shorthand padding */
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    padding-left: 0.75rem;
    padding-right: 2rem;
    min-width: 9.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238b949e' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 12px 12px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Compact variant for toolbars / bottom bars — keeps chevron clearance */
.theme-selector-dropdown--sm {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    padding-left: 0.5rem;
    padding-right: 1.75rem;
    min-width: 8.5rem;
    font-size: 0.75rem;
}

.theme-selector-dropdown:hover {
    border-color: var(--accent-primary);
}

.theme-selector-dropdown:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--focus-ring);
}

/* Light theme dropdown arrow color adjustment */
:root[data-theme="light-modern"] .theme-selector-dropdown {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23656d76' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

/* ============================================
   COMMON UTILITY CLASSES
   ============================================ */

/* Base body styles */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Card styles */
.card-modern {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
}

/* Header styles */
.header-modern {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-primary);
}

/* Footer styles */
.footer-modern {
    background-color: var(--footer-bg);
    border-top: 1px solid var(--border-primary);
    color: var(--text-secondary);
}

/* Button styles */
.btn-modern-primary {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.btn-modern-primary:hover {
    opacity: 0.9;
    box-shadow: 0 2px 8px rgba(139, 163, 188, 0.25);
}

.btn-modern-secondary {
    background-color: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.btn-modern-secondary:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-modern-danger {
    background-color: transparent;
    color: var(--accent-danger);
    border: 1px solid var(--accent-danger);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.btn-modern-danger:hover {
    background-color: var(--accent-danger);
    color: var(--btn-danger-text);
}

/* Input styles */
.input-modern {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.input-modern:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--focus-ring);
}

.input-modern::placeholder {
    color: var(--text-muted);
}

/* Modal styles */
.modal-modern .modal-content {
    background-color: var(--modal-bg);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-modern .modal-header {
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-primary);
}

.modal-modern .modal-footer {
    border-top: 1px solid var(--border-primary);
}

/* Table styles */
.table-modern {
    border-collapse: collapse;
    width: 100%;
}

.table-modern th {
    background-color: var(--table-header-bg);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-accent);
}

.table-modern td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--table-border);
    color: var(--text-primary);
}

.table-modern tbody tr:hover {
    background-color: var(--table-row-hover);
}

/* Status color classes (consistent across themes) */
.status-red { background-color: var(--status-red); color: #ffffff; }
.status-green { background-color: var(--status-green); color: #ffffff; }
.status-amber { background-color: var(--status-amber); color: #000000; }
.status-yellow { background-color: var(--status-yellow); color: #000000; }
.status-blue { background-color: var(--status-blue); color: #ffffff; }
.status-light-blue { background-color: var(--status-light-blue); color: #ffffff; }
.status-brown { background-color: var(--status-brown); color: #ffffff; }
.status-grey { background-color: var(--status-grey); color: #ffffff; }
.status-black { background-color: var(--status-black); color: #ffffff; }
.status-greenblue { background-color: var(--status-greenblue); color: #000000; }
.status-clear { background-color: transparent; color: var(--text-primary); }

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: var(--radius);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Selection styles */
::selection {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
}

/* Link styles */
a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}

a:hover {
    color: var(--accent-primary);
    opacity: 0.8;
}

/* Badge styles */
.badge-modern {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius);
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
}

.badge-modern.badge-success {
    background-color: rgba(63, 185, 80, 0.15);
    color: var(--accent-secondary);
    border-color: rgba(63, 185, 80, 0.3);
}

.badge-modern.badge-warning {
    background-color: rgba(210, 153, 34, 0.15);
    color: var(--accent-warning);
    border-color: rgba(210, 153, 34, 0.3);
}

.badge-modern.badge-danger {
    background-color: rgba(248, 81, 73, 0.15);
    color: var(--accent-danger);
    border-color: rgba(248, 81, 73, 0.3);
}

.badge-modern.badge-info {
    background-color: rgba(139, 163, 188, 0.15);
    color: var(--accent-primary);
    border-color: rgba(139, 163, 188, 0.3);
}
