/* Innoventory-style Dark UI Theme */
@import url('https://fonts.googleapis.com/css2?family=Segoe+UI:wght@300;400;600&display=swap');

:root {
    /* Dark Mode Palette */
    --primary-color: #4da3ff;
    /* Lighter blue for dark bg */
    --primary-hover: #1a73e8;
    --accent-color: #64b5f6;

    --bg-body: #121212;
    /* Very dark gray/black */
    --bg-window: #1e1e1e;
    /* Dark gray for panels */
    --bg-header: #2d2d2d;
    /* Slightly lighter for headers */
    --bg-input: #333333;

    --text-main: #e0e0e0;
    /* Off-white text */
    --text-muted: #a0a0a0;
    --text-inverse: #000000;

    --border-color: #444444;
    --border-focus: #4da3ff;

    --input-focus-bg: #404040;

    --success: #66bb6a;
    --warning: #ffa726;
    --danger: #ef5350;

    /* Spacing & Density */
    --radius: 4px;
    /* Slight radius for modern feel */
    --header-height: 80px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* UNIVERSAL CAPSLOCK RULE */
input[type="text"],
input[type="search"],
textarea {
    text-transform: uppercase;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.3;
    /* Tighter line height */
    overflow-x: hidden;
}

/* --- Layout Structure --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Layout Wrapper for Sidebar + Content */
.main-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 220px;
    background-color: var(--bg-window);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    background: linear-gradient(to right, #1a237e, #0d47a1);
    color: white;
    padding: 8px 10px;
    font-weight: bold;
    font-size: 13px;
    border-bottom: 1px solid #000;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li a {
    display: block;
    padding: 8px 15px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.sidebar-menu li a:hover {
    background-color: #333;
    color: var(--text-main);
}

.sidebar-menu li a.active {
    background-color: #2c3e50;
    color: var(--primary-color);
    font-weight: bold;
    border-left: 3px solid var(--primary-color);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-body);
}

/* Top Window Header */
.top-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 0 10px;
    height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-controls {
    display: flex;
    gap: 5px;
}

.window-control {
    width: 30px;
    height: 20px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
}

.window-control:hover {
    background: #444;
    border: 1px solid var(--border-color);
}

.window-control.closethis:hover {
    background: #d32f2f;
    color: white;
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

/* --- Global Modal / Dialog Styles --- */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: var(--bg-window);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    width: 450px;
    max-width: 90%;
    position: relative;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.15s ease-out;
    border-radius: 6px;
    margin: auto;
    /* Fallback for flex centering */
}

/* --- Common UI Components --- */

/* Windows-style Containers */
.window-box {
    background: var(--bg-window);
    border: 1px solid var(--border-color);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    padding: 10px;
    margin-bottom: 10px;
    border-radius: var(--radius);
}

.window-title {
    background: linear-gradient(to right, #333, #222);
    padding: 5px 10px;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
    margin: -10px -10px 10px -10px;
    font-size: 13px;
    color: var(--text-main);
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

/* Grid System */
.dense-grid {
    display: grid;
    gap: 10px;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 15px;
    /* More breathing room */
    display: flex;
    flex-direction: column;
    /* Stack label and input for better mobile/modern look */
    gap: 5px;
}

.form-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #444;
    font-size: 13px;
    height: 34px;
    /* Taller for better feel */
    background-color: #2a2a2a;
    color: var(--text-main);
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.form-control:focus {
    background-color: #333 !important;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(77, 163, 255, 0.2);
    outline: none;
}

/* Also target inputs inside tables */
table input:focus {
    background-color: var(--input-focus-bg) !important;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    /* Larger click area */
    border: 1px solid #555;
    background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    white-space: nowrap;
    /* Prevent wrapping */
}

.btn-sm {
    padding: 4px 8px;
    font-size: 11px;
}


.btn:hover {
    border-color: #666;
    background: linear-gradient(to bottom, #444, #333);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.btn:active {
    transform: translateY(0);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-primary {
    border: 1px solid #0d47a1;
    background: linear-gradient(to bottom, #1976d2, #1565c0);
    color: white;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(to bottom, #2196f3, #1976d2);
    border-color: #2196f3;
}

/* Tables / Data Grids */
.data-grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-window);
    border: 1px solid var(--border-color);
}

.data-grid th {
    background: #333;
    border: 1px solid var(--border-color);
    padding: 5px 8px;
    /* Compact Header */
    text-align: left;
    font-weight: 600;
    color: var(--text-main);
    font-size: 12px;
    white-space: nowrap;
}

.data-grid td {
    border: 1px solid var(--border-color);
    padding: 3px 6px;
    /* Ultra Compact Rows matches Ledger */
    font-size: 12px;
    color: var(--text-muted);
    vertical-align: middle;
}

.data-grid tr:nth-child(even) {
    background-color: #242424;
}

.data-grid tr:hover {
    background-color: #383838;
    cursor: default;
}

.data-grid td {
    color: #ccc;
}

.data-grid tr:hover td {
    color: #fff;
}

/* Common Dark Table (Alias for data-grid with compact sizing) */
.dark-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-window);
    border: 1px solid var(--border-color);
}

.dark-table th {
    background: #2d2d2d;
    border: 1px solid var(--border-color);
    padding: 6px 8px;
    /* Compact */
    text-align: left;
    font-weight: 600;
    color: #e0e0e0;
    font-size: 13px;
}

.dark-table td {
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    /* Compact Row Height */
    font-size: 13px;
    color: #b0b0b0;
    vertical-align: middle;
}

.dark-table tr:nth-child(even) {
    background-color: #262626;
}

.dark-table tr:hover {
    background-color: #333;
}

/* Helper Utility */
.text-right {
    text-align: right;
}

.w-full {
    width: 100%;
}

.login-logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 20px;
    text-transform: uppercase;
    text-align: center;
}

/* --- Tabbed Interface Styles --- */
.tab-bar {
    display: flex;
    background: #222;
    border-bottom: 1px solid var(--border-color);
    padding: 3px 5px 0 5px;
    gap: 4px;
    height: 32px;
    flex-shrink: 0;
}

.tab {
    background: #333;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    max-width: 160px;
    justify-content: space-between;
    user-select: none;
    color: #aaa;
    transition: background 0.2s;
}

.tab:hover {
    background: #444;
    color: #fff;
}

.tab.active {
    background: var(--bg-body);
    font-weight: bold;
    color: var(--primary-color);
    border-bottom: 1px solid var(--bg-body);
    margin-bottom: -1px;
    position: relative;
    z-index: 10;
}

.tab-close {
    font-size: 14px;
    line-height: 14px;
    color: #888;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-close:hover {
    background: #d32f2f;
    color: white;
}

.frames-container {
    flex: 1;
    position: relative;
    background: var(--bg-body);
    overflow: hidden;
}

.tab-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: none;
}

/* Scrollbar Styling for Dark Mode */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #222;
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Selected Row Highlighting */
.data-grid tr.selected-row,
.dark-table tr.selected-row {
    background-color: #1565C0 !important;
    /* Bright Blue */
    position: relative;
    z-index: 10;
    box-shadow: 0 0 0 2px #64B5F6 inset;
    /* Light Blue Inset Border */
}

.data-grid tr.selected-row td,
.dark-table tr.selected-row td {
    background-color: #1565C0 !important;
    color: white !important;
    border-color: #42A5F5;
}

/* Prevent text selection when clicking rows (Disabled for Copy capability) */
.data-grid tr,
.dark-table tr {
    /* user-select: none; */
}

/* Danger Button Highlighting */
.btn-danger {
    background: linear-gradient(to bottom, #d32f2f, #c62828);
    border: 1px solid #b71c1c;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(to bottom, #f44336, #d32f2f);
    border-color: #f44336;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.btn-danger:disabled {
    background: #3a3a3a;
    /* Fallback to standard disabled look if needed, but usually handled by removing class */
    border: 1px solid #555;
    color: #888;
    cursor: not-allowed;
    /* Remove gradient */
}

/* Shared Autocomplete Styles */
.autocomplete-suggestions {
    border: 1px solid var(--border-color);
    background: var(--bg-window);
    overflow: auto;
    position: absolute;
    z-index: 9999;
    max-height: 200px;
    width: 100%;
    /* Match Input Width */
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.autocomplete-suggestion {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-main);
    border-bottom: 1px solid #333;
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

.autocomplete-suggestion:hover {
    background-color: #333;
}

.autocomplete-active {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
}

.suggestion-row {
    display: flex;
    justify-content: space-between;
}

.suggestion-name {
    font-weight: bold;
}

.suggestion-meta {
    font-size: 0.9em;
    color: #aaa;
}

.suggestion-extra {
    font-size: 0.8em;
    color: #888;
    margin-top: 4px;
}

.yellow-input {
    background-color: #FFFF00 !important;
    font-weight: bold;
    color: #000 !important;
}