/* ========================================
   XBRL Financial Data Entry System - Styles
   ======================================== */

/* CSS Custom Properties */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: #1c1e2e;
    --bg-card-hover: #222440;
    --bg-input: #12131f;
    --bg-input-focus: #1a1c30;
    --border-color: #2a2d42;
    --border-focus: #6366f1;
    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa8;
    --text-muted: #5c6080;
    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-secondary: #8b5cf6;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;
    --blue-input-bg: rgba(99, 102, 241, 0.08);
    --blue-input-border: rgba(99, 102, 241, 0.3);
    --blue-input-focus: rgba(99, 102, 241, 0.15);
    --sidebar-width: 280px;
    --sidebar-collapsed: 0px;
    --top-bar-height: 70px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* Scrollbar */
::-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);
}

/* App Layout */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ====== SIDEBAR ====== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: all var(--transition-slow);
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
    min-height: 60px;
}

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

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}
.sidebar-toggle:hover {
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.nav-group {
    margin-bottom: 6px;
}

.nav-group-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 10px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.85rem;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.1));
    color: var(--accent-primary-hover);
    font-weight: 500;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: var(--accent-primary);
    border-radius: 0 3px 3px 0;
}

.nav-item-code {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 52px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.nav-item.active .nav-item-code {
    color: var(--accent-primary);
}

.nav-item-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item-badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(99,102,241,0.15);
    color: var(--accent-primary);
    font-weight: 600;
}

.nav-item.has-data .nav-item-badge {
    background: rgba(34,197,94,0.15);
    color: var(--accent-success);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ====== MAIN CONTENT ====== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    min-height: var(--top-bar-height);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.page-info {
    flex: 1;
    min-width: 0;
}

.page-info h1 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.progress-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.progress-bar {
    width: 80px;
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
    transition: width var(--transition-normal);
}

/* ====== FORM CONTAINER ====== */
.form-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Section: General Info (Form layout) */
.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.form-section-title .section-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: 0.85rem;
}

/* Form Field */
.form-field {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(42, 45, 66, 0.5);
    align-items: start;
}

.form-field:last-child {
    border-bottom: none;
}

.field-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.field-label-id {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.field-label-en {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.field-input-wrapper {
    width: 100%;
}

/* Input styles */
.input-field {
    width: 100%;
    padding: 8px 12px;
    background: var(--blue-input-bg);
    border: 1px solid var(--blue-input-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    transition: all var(--transition-fast);
    outline: none;
}

.input-field:hover {
    border-color: var(--accent-primary);
    background: var(--blue-input-focus);
}

.input-field:focus {
    border-color: var(--accent-primary);
    background: var(--blue-input-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.input-field::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.input-field.read-only {
    background: var(--bg-input);
    border-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.7;
}

select.input-field {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

textarea.input-field {
    min-height: 60px;
    resize: vertical;
}

/* ====== FINANCIAL TABLE ====== */
.financial-table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.financial-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.financial-table thead th {
    background: linear-gradient(180deg, rgba(99,102,241,0.1), rgba(99,102,241,0.05));
    padding: 12px 16px;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
    color: var(--accent-primary-hover);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    z-index: 5;
}

.financial-table thead th.col-value {
    text-align: right;
    min-width: 180px;
}

.financial-table tbody tr {
    transition: background var(--transition-fast);
}

.financial-table tbody tr:hover {
    background: rgba(99,102,241,0.03);
}

.financial-table tbody td {
    padding: 6px 16px;
    border-bottom: 1px solid rgba(42,45,66,0.3);
    vertical-align: middle;
}

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

/* Row classifications */
.financial-table tbody tr.row-header td {
    font-weight: 600;
    color: var(--accent-primary-hover);
    padding-top: 14px;
    font-size: 0.88rem;
    background: rgba(99,102,241,0.04);
}

.financial-table tbody tr.row-subheader td {
    font-weight: 600;
    color: var(--text-primary);
    padding-top: 10px;
    font-size: 0.85rem;
}

.financial-table tbody tr.row-total td {
    font-weight: 700;
    color: var(--accent-primary-hover);
    border-top: 2px solid var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
    background: rgba(99,102,241,0.06);
    font-size: 0.88rem;
}

.financial-table tbody tr.row-subtotal td {
    font-weight: 600;
    border-top: 1px solid var(--border-color);
    background: rgba(99,102,241,0.03);
}

.cell-label {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cell-label-id {
    font-size: 0.83rem;
}

.cell-label-en {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

.cell-indent-1 .cell-label { padding-left: 16px; }
.cell-indent-2 .cell-label { padding-left: 32px; }
.cell-indent-3 .cell-label { padding-left: 48px; }

.cell-input {
    text-align: right;
    padding: 4px 8px;
}

.cell-input .input-field {
    text-align: right;
    padding: 6px 10px;
    font-size: 0.83rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* Changes in equity table */
.equity-table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

.equity-table {
    min-width: 1200px;
}

.equity-table thead th {
    min-width: 100px;
    font-size: 0.68rem;
    padding: 8px 6px;
    text-align: center;
    white-space: normal;
    line-height: 1.3;
}

.equity-table tbody td {
    padding: 4px 6px;
    font-size: 0.78rem;
}

.equity-table .cell-input .input-field {
    font-size: 0.78rem;
    padding: 4px 6px;
}

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-outline:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.btn-success {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: white;
    box-shadow: 0 2px 8px rgba(34,197,94,0.3);
}
.btn-success:hover {
    box-shadow: 0 4px 14px rgba(34,197,94,0.45);
    transform: translateY(-1px);
    background: linear-gradient(135deg, #15803d, #16a34a);
}

/* ====== TOAST ====== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-slow);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 3px solid var(--accent-success);
}
.toast.error {
    border-left: 3px solid var(--accent-danger);
}
.toast.info {
    border-left: 3px solid var(--accent-info);
}

/* ====== MOBILE OVERLAY ====== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 99;
    backdrop-filter: blur(4px);
}

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

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -280px;
        transition: left var(--transition-slow);
    }
    .sidebar.open {
        left: 0;
    }
    .mobile-menu-toggle {
        display: flex;
    }
    .form-field {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .progress-indicator {
        display: none;
    }
}

@media (max-width: 640px) {
    html { font-size: 13px; }
    .form-container { padding: 12px; }
    .form-section { padding: 16px; }
    .top-bar { padding: 0 12px; }
    .financial-table thead th,
    .financial-table tbody td {
        padding: 6px 10px;
    }
}

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

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.5;
}
.empty-state p {
    font-size: 0.85rem;
}
