/* INTELLIGENCE FINANCE - PROFESSIONAL DESIGN SYSTEM */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap');

:root {
    /* Core Brand Colors */
    --primary: #011738;
    --primary-light: #1a2332;
    --primary-dark: #000c1f;
    --accent: #00aeef;
    --accent-light: #33bef2;
    --accent-dark: #0088cc;
    --accent-glow: #00aeef33;
    
    /* Semantic Colors */
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #00d4aa;
    --warning: #ffa726;
    --error: #ff4757;
    
    /* Surface Colors */
    --surface-primary: #0a0e1a;
    --surface-secondary: #1a1a1a;
    --surface-elevated: #1f1f1f;
    --glass-bg: rgba(26, 35, 50, 0.8);
    --glass-border: rgba(0, 174, 239, 0.2);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    
    /* Typography */
    --font-interface: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* GLOBAL RESET & BASE */
html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* Completely prevent document scrolling */
    position: relative;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    direction: ltr;
    text-align: left;
    overflow: hidden; /* Prevent any body scrolling */
    font-family: var(--font-interface);
    background: var(--surface-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    position: relative; /* Keep normal positioning */
}

/* ANIMATED BACKGROUND PATTERN - FIXED */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw; /* Use viewport width */
    height: 100vh; /* Use viewport height */
    opacity: 0.03;
    background-image: 
        linear-gradient(rgba(0, 174, 239, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 174, 239, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    background-repeat: repeat;
    animation: gridShift 20s infinite linear;
    pointer-events: none;
    z-index: -1;
    overflow: hidden; /* Prevent any overflow from animation */
}

@keyframes gridShift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(25px, 25px); } /* Reduced movement to prevent scrollbars */
}

/* HEADER */
.main-header {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-bottom: 2px solid var(--accent);
    position: relative;
}

.main-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, var(--accent), transparent, var(--accent));
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.header-img {
    width: 100%;
    height: auto;
    display: block;
}

/* FLEX LAYOUT AFTER HEADER */
.container {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden; /* Prevent container from creating scrollbars */
}

/* SIDEBAR */
.sidebar {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    width: 260px;
    padding: 24px;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    position: relative;
    overflow-y: auto;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: var(--glass-border);
}

.sidebar h2 {
    margin-top: 0;
    font-family: var(--font-heading);
    font-size: 22px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 12px;
    margin-bottom: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar ul li {
    margin: 8px 0;
}

.sidebar a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 400;
    padding: 12px 16px;
    border-radius: 8px;
    display: block;
    transition: all 0.3s ease;
    font-size: 14px;
    position: relative;
    overflow: hidden;
    font-family: var(--font-interface);
}

.sidebar a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), transparent);
    transition: width 0.3s ease;
}

.sidebar a:hover {
    color: var(--accent);
    background: rgba(0, 174, 239, 0.1);
    transform: translateX(4px);
}

.sidebar a:hover::before {
    width: 4px;
}

.sidebar a.active {
    color: var(--accent);
    background: rgba(0, 174, 239, 0.15);
    font-weight: 600;
}

/* Special styling for nested menu items if you have any */
.sidebar ul ul {
    margin-left: 16px;
    border-left: 1px solid rgba(0, 174, 239, 0.2);
    padding-left: 8px;
}

.sidebar ul ul a {
    font-size: 13px;
    padding: 8px 12px;
    color: rgba(148, 163, 184, 0.8);
}

/* Add subtle animation to sidebar on page load */
.sidebar {
    animation: slideInLeft 0.5s ease-out;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* MAIN CONTENT COLUMN */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* CONTENT AREA */
.content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    background: var(--surface-primary);
    color: var(--text-primary);
    position: relative;
}

/* FOOTER */
.footer {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--text-secondary);
    text-align: center;
    padding: 16px 20px;
    font-size: 13px;
    border-top: 2px solid var(--accent);
    position: relative;
    font-family: var(--font-interface);
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

/* TYPOGRAPHY */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 24px;
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.2;
}

h1 {
    font-size: 36px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    font-weight: 700;
}

h2 {
    font-size: 28px;
    color: var(--text-primary);
    font-weight: 600;
}

h3 {
    font-size: 22px;
    color: var(--text-primary);
    font-weight: 500;
}

/* FORM ELEMENTS - FIXED ALIGNMENT */
form {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    text-align: left;
    direction: ltr;
}

form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent, var(--accent));
    animation: shimmer 3s infinite;
}

form label {
    font-weight: 600;
    display: block;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    text-align: left;
    direction: ltr;
    width: 100%;
    float: none;
    clear: both;
}

form input[type="text"],
form input[type="date"],
form input[type="number"],
form input[type="file"],
form input[type="email"],
form input[type="password"],
form select,
form textarea {
    width: 100%;
    padding: 16px 20px;
    margin-top: 8px;
    font-size: 15px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    background: rgba(26, 35, 50, 0.6);
    color: var(--text-primary);
    font-family: var(--font-interface);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    text-align: left;
    direction: ltr;
    display: block;
    box-sizing: border-box;
    float: none;
    clear: both;
    margin-left: 0;
    margin-right: 0;
}

form input:focus,
form select:focus,
form textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(26, 35, 50, 0.8);
    box-shadow: 0 0 0 3px var(--accent-glow);
    transform: translateY(-1px);
}

form input::placeholder {
    color: rgba(148, 163, 184, 0.6);
}

/* FORM GROUP CONTAINERS - ENSURE PROPER ALIGNMENT */
.form-group,
.field-container,
.input-container,
.form-field,
.field-wrapper,
.input-wrapper {
    width: 100%;
    text-align: left;
    direction: ltr;
    display: block;
    clear: both;
    margin-left: 0;
    margin-right: 0;
    float: none;
    box-sizing: border-box;
}

/* BUTTONS */
.btn, form button {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    margin-top: 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px var(--accent-glow);
    font-family: var(--font-interface);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 12px;
    margin-bottom: 8px;
    text-align: center;
}

.btn::before, form button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover, form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--accent-glow);
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
}

.btn:hover::before, form button:hover::before {
    left: 100%;
}

/* Button Variants */
.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-success, .btn-add {
    background: linear-gradient(135deg, var(--success) 0%, #00b894 100%);
    box-shadow: 0 4px 16px rgba(0, 212, 170, 0.3);
}

.btn-warning, .btn-save {
    background: linear-gradient(135deg, var(--warning) 0%, #ff9800 100%);
    box-shadow: 0 4px 16px rgba(255, 167, 38, 0.3);
}

.btn-danger, .btn-delete {
    background: linear-gradient(135deg, var(--error) 0%, #ff3742 100%);
    box-shadow: 0 4px 16px rgba(255, 71, 87, 0.3);
    padding: 12px 24px;
    font-size: 14px;
}

.btn-secondary, .btn-back {
    background: linear-gradient(135deg, var(--surface-elevated) 0%, var(--primary-light) 100%);
    color: var(--text-secondary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* TABLES */
.table-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    border: 1px solid var(--glass-border);
    margin-bottom: 24px;
    position: relative;
}

.table-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent, var(--accent));
    animation: shimmer 3s infinite;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
}

th {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: var(--text-primary);
    padding: 18px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    position: relative;
}

th::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--accent);
}

td {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    color: var(--text-primary);
    font-size: 14px;
}

tr:hover td {
    background-color: rgba(0, 174, 239, 0.05);
}

tr:last-child td {
    border-bottom: none;
}

/* CROSSWALK TABLE INPUTS */
.crosswalk-table input[type="text"], 
.crosswalk-table input[type="number"] {
    width: 100%;
    border: none;
    padding: 12px 16px;
    background-color: transparent;
    color: var(--text-primary);
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-family: var(--font-interface);
    text-align: left;
    direction: ltr;
}

.crosswalk-table input:hover {
    background-color: rgba(0, 174, 239, 0.05);
}

.crosswalk-table input:focus {
    outline: none;
    background-color: rgba(0, 174, 239, 0.1);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* LINKS */
a {
    color: var(--accent);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: var(--accent-light);
    text-decoration: underline;
}

/* FLASH MESSAGES */
.flash-messages {
    margin: 24px 0;
}

.flash-message {
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flash-message.success {
    background: rgba(0, 212, 170, 0.1);
    border-color: rgba(0, 212, 170, 0.3);
    color: var(--success);
}

.flash-message.error {
    background: rgba(255, 71, 87, 0.1);
    border-color: rgba(255, 71, 87, 0.3);
    color: var(--error);
}

.flash-message.warning {
    background: rgba(255, 167, 38, 0.1);
    border-color: rgba(255, 167, 38, 0.3);
    color: var(--warning);
}

/* NAVIGATION */
.crosswalk-nav {
    display: flex;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    margin-bottom: 32px;
    border-radius: 16px;
    padding: 8px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--glass-border);
    position: relative;
}

.crosswalk-nav::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent, var(--accent));
    animation: shimmer 3s infinite;
}

.crosswalk-nav a {
    flex: 1;
    color: var(--text-secondary);
    text-align: center;
    padding: 16px 32px;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
    border-radius: 12px;
    margin: 2px;
    position: relative;
    overflow: hidden;
    font-family: var(--font-interface);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.crosswalk-nav a:hover {
    color: var(--text-primary);
    background-color: rgba(0, 174, 239, 0.1);
    transform: translateY(-1px);
}

.crosswalk-nav a.active {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    box-shadow: 0 4px 16px var(--accent-glow);
    font-weight: 600;
}

/* ACTION BUTTONS */
.action-buttons {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    flex-wrap: wrap;
    align-items: center;
}

/* ROW STATES */
.modified {
    background-color: rgba(255, 167, 38, 0.1) !important;
    position: relative;
}

.modified::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--warning) 0%, #ff9800 100%);
}

.deleted {
    background-color: rgba(255, 71, 87, 0.1) !important;
    opacity: 0.6;
}

.deleted td {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* INFO AND WARNING BOXES */
.info-box, .warning-box {
    padding: 20px 24px;
    margin-bottom: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    backdrop-filter: blur(10px);
    border: 1px solid;
}

.info-box {
    background: rgba(0, 174, 239, 0.1);
    border-color: rgba(0, 174, 239, 0.3);
    color: var(--accent);
}

.warning-box {
    background: rgba(255, 167, 38, 0.1);
    border-color: rgba(255, 167, 38, 0.3);
    color: var(--warning);
}

/* SCROLLBAR STYLING */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--surface-secondary);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
    border-radius: 6px;
    border: 2px solid var(--surface-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
}

/* LOADING STATES */
.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid transparent;
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .sidebar {
        width: 220px;
        padding: 16px;
    }
    
    .sidebar h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .sidebar a {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .content {
        padding: 20px;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn {
        justify-content: center;
        margin-right: 0;
    }
    
    .crosswalk-nav {
        flex-direction: column;
        gap: 4px;
    }
    
    .table-container {
        padding: 16px;
        font-size: 14px;
    }
}

@media (max-width: 640px) {
    body {
        height: 100vh;
        overflow: hidden;
    }
    
    .container {
        flex-direction: column;
        height: 100%;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 150px;
        overflow-y: auto;
        flex-shrink: 0;
    }
    
    .content {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
    }
    
    h1 {
        font-size: 28px;
    }
    
    h2 {
        font-size: 24px;
    }
}

/* GLOBAL OVERFLOW PREVENTION */
html {
    overflow-x: hidden;
    overflow-y: hidden; /* Prevent vertical document scrolling */
}

* {
    box-sizing: border-box;
}

/* Ensure no element causes horizontal overflow */
*:not(code):not(pre) {
    max-width: 100%;
}

/* Prevent any content from forcing document scroll */
body > * {
    max-height: 100vh;
}

/* Disable scroll restoration that might cause jumping */
html {
    scroll-behavior: auto;
}

/* Prevent touch/wheel scrolling on document */
body {
    touch-action: none;
    overscroll-behavior: none;
}

/* Prevent animation-induced scrollbars */
@media (prefers-reduced-motion: reduce) {
    body::before {
        animation: none;
    }
    
    .main-header::after {
        animation: none;
    }
    
    .form-container::before,
    .table-container::before,
    .crosswalk-nav::before {
        animation: none;
    }
}

/* ADDITIONAL FORM ALIGNMENT FIXES */
* {
    box-sizing: border-box;
}

/* Override any problematic float or positioning */
form input:not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]) {
    float: none !important;
    text-align: left !important;
    direction: ltr !important;
}

/* Ensure form containers don't force right alignment */
.form-container,
.upload-form,
.main-form {
    text-align: left;
    direction: ltr;
}