@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    color: #fff;
}

body {
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 50%, #0d1117 100%);
    background-attachment: fixed;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 50%, #0d1117 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99998;
}

.login-screen.hidden {
    display: none;
}

.login-content {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 48px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.05);
}

.login-logo {
    width: 100px;
    height: auto;
    margin-bottom: 24px;
}

.login-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 32px;
}

.password-input {
    width: 100%;
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.8);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.95);
    font-size: 1rem;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.password-input:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.password-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.login-error {
    color: #ef4444;
    font-size: 0.875rem;
    min-height: 20px;
    margin-bottom: 16px;
}

.login-button {
    width: 100%;
    padding: 16px 32px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

.login-button:active {
    transform: translateY(0);
}

.login-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    transition: clip-path 0.8s ease-out, visibility 0.8s ease-out;
}

#loading-screen.pour-out {
    clip-path: inset(0 0 100% 0);
    visibility: hidden;
}

.loader {
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-logo {
    width: 120px;
    height: auto;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes heroFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

html {
    scroll-behavior: smooth;
}

/* Upload Section */
.upload-section {
    margin-bottom: 40px;
    padding: 40px;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 
                0 0 0 1px rgba(255, 255, 255, 0.05),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.upload-section label {
    display: block;
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.upload-section input[type="file"] {
    display: block;
    width: 100%;
    margin-bottom: 24px;
    background: rgba(15, 23, 42, 0.8);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-section input[type="file"]:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(15, 23, 42, 0.9);
}

.upload-section input[type="file"]::file-selector-button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    margin-right: 15px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.upload-section input[type="file"]::file-selector-button:hover {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.upload-section button {
    width: 100%;
    padding: 16px 32px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5),
                0 0 0 0 rgba(59, 130, 246, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.upload-section button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.6),
                0 0 0 0 rgba(59, 130, 246, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

.upload-section button:active {
    transform: translateY(0);
}

.upload-section button:disabled {
    background: rgba(255, 255, 255, 0.05);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}

.blast-section {
    margin-top: 40px;
    padding: 40px;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 
                0 0 0 1px rgba(255, 255, 255, 0.05),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.blast-section button {
    width: 100%;
    padding: 18px 36px;
    background: linear-gradient(135deg, #06b6d4 0%, #10b981 100%);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.5),
                0 0 0 0 rgba(6, 182, 212, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.blast-section button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(6, 182, 212, 0.6),
                0 0 0 0 rgba(6, 182, 212, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, #22d3ee 0%, #34d399 100%);
}

.blast-section button:active {
    transform: translateY(0);
}

.blast-section button:disabled {
    background: rgba(255, 255, 255, 0.05);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}

body {
    padding: 40px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    font-size: 2.75rem;
    font-weight: 700;
    margin-bottom: 40px;
    text-align: center;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #ffffff 0%, #a0aec0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(20px);
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    display: table;
    margin: 0;
    border-radius: 0;
    overflow: visible;
}

th, td {
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 16px 12px;
    text-align: left;
}

th {
    font-size: 0.75rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.15) 100%);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.95);
    border-bottom: 2px solid rgba(59, 130, 246, 0.3);
    white-space: nowrap;
}

/* Column resize handle */
.col-resizer {
    position: absolute;
    right: 0;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
}
.col-resizer:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Name column - moderate width with ellipsis */
th:first-child,
td:first-child {
    min-width: 240px;
    width: 260px;
    max-width: 320px;
}

td:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Make the first (Name) column sticky for horizontal scroll */
th:first-child {
    position: sticky;
    left: 0;
    z-index: 3; /* above sticky cells */
    background: #0f172a !important; /* solid, non-transparent */
    backdrop-filter: none;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #0f172a !important; /* solid, non-transparent base */
    backdrop-filter: none;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

/* Explicit solid colors for sticky first column row states */
tr:nth-child(even) td:first-child {
    background-color: #101b33 !important;
}

tr:hover td:first-child {
    background-color: #0e2238 !important;
}

/* Quantity column */
th:nth-child(2),
td:nth-child(2) {
    min-width: 100px;
    width: 100px;
}

/* Cost columns */
th:nth-child(3),
td:nth-child(3),
th:nth-child(4),
td:nth-child(4),
th:nth-child(5),
td:nth-child(5) {
    min-width: 140px;
    width: 140px;
}

/* Checkbox columns */
th:nth-child(6),
td:nth-child(6),
th:nth-child(7),
td:nth-child(7) {
    min-width: 120px;
    width: 120px;
}

td {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    word-wrap: break-word;
    overflow-wrap: break-word;
}


td input {
    font-size: 0.875rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 12px;
    color: rgba(255, 255, 255, 0.95);
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

/* Specific input widths */
td input[type="text"] {
    min-width: 380px;
    width: 100%;
}

td input[type="number"] {
    min-width: 100px;
    width: 100%;
}

td input:focus {
    outline: none;
    border-color: rgba(6, 182, 212, 0.5);
    background: rgba(6, 182, 212, 0.05);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

td input:read-only {
    background: rgba(255, 255, 255, 0.03);
    cursor: not-allowed;
}

tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

tr:hover {
    background-color: rgba(59, 130, 246, 0.05);
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    color: #fff;
    box-sizing: border-box;
    font-size: 1.5rem;
    font-family: "Amatic SC", sans-serif;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #fff;
    background-color: rgba(0, 0, 0, 0.7);
}

input[type="text"]:read-only,
input[type="number"]:read-only {
    background-color: rgba(255, 255, 255, 0.1);
    cursor: not-allowed;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer !important;
    margin-right: 5px;
    accent-color: #6366f1;
}

/* Ensure checkbox wrappers never inherit a not-allowed cursor */
.include-checkbox,
.field-checkbox,
.field-checkbox-label,
.row-options label {
    cursor: pointer !important;
}

/* Guard against any inherited not-allowed cursor on inputs */
td input[type="checkbox"],
.invoice-cards input[type="checkbox"] {
    cursor: pointer !important;
}

/* Custom Alert Styles */
.custom-alert {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.custom-alert.show {
    display: flex;
}

.custom-alert-content {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.05);
    text-align: center;
    animation: slideUp 0.3s ease;
}

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

.custom-alert-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.custom-alert-icon.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(220, 38, 38, 0.2) 100%);
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.custom-alert-icon.error::before {
    content: "⚠";
}

.custom-alert-icon.success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(22, 163, 74, 0.2) 100%);
    border: 2px solid rgba(34, 197, 94, 0.3);
}

.custom-alert-icon.success::before {
    content: "✓";
}

.custom-alert-message {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    margin-bottom: 24px;
    word-wrap: break-word;
}

.custom-alert-button {
    padding: 12px 32px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.custom-alert-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

.custom-alert-button:active {
    transform: translateY(0);
}

label {
    font-weight: normal;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-size: 0.875rem;
}

.include-checkbox {
    text-align: center;
}


.section-header {
    margin-top: 30px;
    font-size: 1.125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.01em;
}

/* Desktop card styles */
.invoice-cards {
    display: none;
}

.row-options {
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    margin-bottom: 10px;
}

.row-options label {
    margin-right: 20px;
    font-size: 0.875rem;
}

/* Loading Screen Overlay */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(10, 14, 39, 0.98) 0%, rgba(26, 31, 58, 0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    flex-direction: column;
    gap: 30px;
}

#loading-screen.show {
    display: flex;
    animation: fadeIn 0.3s ease-in-out;
}

#loading-screen.hide {
    animation: fadeOut 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.loading-content {
    text-align: center;
}

.loader {
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-logo {
    width: 120px;
    height: auto;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 30px;
    color: #fff;
    text-shadow: 0 2px 20px rgba(99, 102, 241, 0.4);
}

.loading-subtext {
    font-size: 0.875rem;
    margin-top: 15px;
    color: rgba(255, 255, 255, 0.6);
}

/* Spinner button styles */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

/* Responsive styles */
@media (max-width: 768px) {
    body {
        padding: 20px 10px;
    }

    h1 {
        font-size: 2rem;
    }

    .upload-section {
        padding: 24px 16px;
    }

    .upload-section label {
        font-size: 0.875rem;
    }

    .upload-section input[type="file"] {
        padding: 12px;
        font-size: 0.875rem;
    }

    .upload-section button {
        font-size: 0.875rem;
        padding: 14px 24px;
    }

    /* Hide table on mobile */
    table {
        display: none !important;
    }

    .table-wrapper {
        display: none !important;
    }

    /* Show cards on mobile */
    .invoice-cards {
        display: block !important;
    }

    .invoice-card {
        background: rgba(17, 24, 39, 0.6);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 16px;
        padding: 20px;
        margin-bottom: 16px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    }

    .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        padding-bottom: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 12px;
    }

    .card-title {
        font-weight: 600;
        font-size: 1rem;
        color: rgba(255, 255, 255, 0.95);
        flex: 1;
    }

    .card-toggle {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(59, 130, 246, 0.1);
        border: 1px solid rgba(59, 130, 246, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        flex-shrink: 0;
    }

    .card-toggle:hover {
        background: rgba(59, 130, 246, 0.2);
        transform: rotate(90deg);
    }

    .card-toggle svg {
        width: 16px;
        height: 16px;
        stroke: rgba(255, 255, 255, 0.9);
        transition: transform 0.3s ease;
    }

    .card-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .invoice-card.expanded .card-content {
        max-height: 2000px;
    }

    .invoice-card.expanded .card-toggle svg {
        transform: rotate(45deg);
    }

    .card-field {
        margin-bottom: 16px;
    }

    .field-label {
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: rgba(255, 255, 255, 0.6);
        margin-bottom: 6px;
        display: block;
    }

    .field-input {
        width: 100%;
        padding: 12px;
        background: rgba(15, 23, 42, 0.8);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        color: rgba(255, 255, 255, 0.95);
        font-size: 0.9375rem;
        transition: all 0.2s ease;
        box-sizing: border-box;
    }

    .field-input:focus {
        outline: none;
        border-color: rgba(59, 130, 246, 0.5);
        background: rgba(59, 130, 246, 0.05);
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }

    .field-input:read-only {
        background: rgba(255, 255, 255, 0.03);
        cursor: not-allowed;
    }

    .field-checkbox-wrapper {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .field-checkbox {
        width: 24px;
        height: 24px;
        cursor: pointer;
        accent-color: #6366f1;
    }

    .field-checkbox-label {
        font-size: 0.875rem;
        color: rgba(255, 255, 255, 0.9);
    }

    .blast-section {
        padding: 24px 16px;
    }

    .blast-section button {
        font-size: 0.875rem;
        padding: 14px 24px;
    }
}
