/* assets/css/style.css */

/* Design Tokens (CSS Variables) */
:root {
    --bg-primary: #f8f9fa;
    --bg-surface: #ffffff;
    --border-color: #dee2e6;
    --primary-accent: #0f62fe;
    --primary-hover: #0043ce;
    --success: #24a148;
    --warning: #f1c21b;
    --danger: #da1e28;
    --text-primary: #161616;
    --text-secondary: #525252;
    --text-muted: #8d8d8d;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --border-radius: 4px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.5;
}

/* Layout */
header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-sm) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.logo a {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.logo span {
    color: var(--primary-accent);
}

nav ul {
    list-style: none;
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius);
    transition: all 0.2s;
}

nav a:hover, nav a.active {
    color: var(--primary-accent);
    background-color: rgba(15, 98, 254, 0.08);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.container {
    max-width: 1200px;
    margin: var(--spacing-lg) auto;
    padding: 0 var(--spacing-md);
}

/* Typography */
h1, h2, h3, h4 {
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    font-weight: 600;
}

p {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

a {
    color: var(--primary-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-accent);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    text-decoration: none;
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

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

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.9;
    text-decoration: none;
}

.btn:disabled {
    background-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Cards */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tables */
table.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-md);
}

table.table th, table.table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table.table th {
    background-color: #f1f3f5;
    font-weight: 600;
    color: var(--text-primary);
}

table.table tr:hover {
    background-color: #f8f9fa;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 14px;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary-accent);
}

.form-control:disabled {
    background-color: var(--bg-primary);
    cursor: not-allowed;
}

.form-row {
    display: flex;
    gap: var(--spacing-md);
}

.form-row .form-group {
    flex: 1;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    text-transform: capitalize;
}

.badge-success {
    background-color: #e5f6e8;
    color: var(--success);
}

.badge-warning {
    background-color: #fef8e2;
    color: #b28300;
}

.badge-danger {
    background-color: #fdebeb;
    color: var(--danger);
}

.badge-info {
    background-color: #e5f0ff;
    color: var(--primary-accent);
}

/* Alerts */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-md);
    border: 1px solid transparent;
}

.alert-success {
    background-color: #e5f6e8;
    border-color: #b2e3be;
    color: #125e27;
}

.alert-danger {
    background-color: #fdebeb;
    border-color: #f9c2c2;
    color: #8c1017;
}

.alert-warning {
    background-color: #fef8e2;
    border-color: #fbe69c;
    color: #805e00;
}

/* Dashboard Module Grid */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.module-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.module-card:hover:not(.disabled) {
    transform: translateY(-2px);
    border-color: var(--primary-accent);
    box-shadow: var(--shadow-md);
}

.module-card .badge {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
}

.module-card.disabled {
    background-color: #f1f3f5;
    border-color: var(--border-color);
    opacity: 0.7;
    cursor: not-allowed;
}

.module-card.disabled h3, .module-card.disabled p {
    color: var(--text-muted);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--spacing-lg);
}

.tab-link {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-link:hover, .tab-link.active {
    color: var(--primary-accent);
    border-bottom-color: var(--primary-accent);
}

/* Spreadsheet-style Table Rules */
.budget-sheet-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    background-color: var(--bg-surface);
}

.budget-sheet {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}

.budget-sheet th, .budget-sheet td {
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    white-space: nowrap;
}

.budget-sheet th {
    background-color: #f1f3f5;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Sticky First Column */
.sticky-col {
    position: sticky;
    left: 0;
    background-color: var(--bg-surface);
    z-index: 5;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}

.budget-sheet th.sticky-col {
    z-index: 15;
    background-color: #f1f3f5;
}

/* Hierarchical Rows styling */
.row-level-0 {
    background-color: #e9ecef;
    font-weight: 700;
}

.row-level-1 {
    background-color: #f8f9fa;
    font-weight: 600;
}

.row-level-2 {
    font-weight: 500;
}

.indent-0 { padding-left: 12px !important; }
.indent-1 { padding-left: 28px !important; }
.indent-2 { padding-left: 44px !important; }

/* Numeric inputs/formatting */
.text-right {
    text-align: right;
}

.val-budget {
    color: var(--text-primary);
}

.val-expense {
    color: var(--danger);
    cursor: pointer;
    font-weight: 500;
}

.val-expense:hover {
    text-decoration: underline;
}

.val-balance {
    font-weight: 500;
}

.val-balance.negative {
    color: var(--danger);
}

.val-balance.positive {
    color: var(--success);
}

/* Interactive expense modal & overlays */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--bg-surface);
    border-radius: var(--border-radius);
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    animation: modal-fade 0.2s ease-out;
}

@keyframes modal-fade {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.close-btn {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-secondary);
}

.close-btn:hover {
    color: var(--text-primary);
}

/* Collapse / Expand categories styles */
.cat-toggle {
    cursor: pointer;
    display: inline-inline-block;
    width: 16px;
    text-align: center;
    margin-right: 4px;
    user-select: none;
}

.collapsed-child {
    display: none !important;
}

/* File upload elements */
.attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-xs);
    background-color: #fdfdfd;
}

/* Search bar styling */
.filter-bar {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-bar .form-group {
    margin-bottom: 0;
}
