:root {
    --ice-light: #EDCF5D;
    --arctic-blue: #70C3CE;
    --polar-blue: #2898AE;
    --deep-blue: #106782;
    --polar-black: #0f172a;
    --snow-white: #fafafa;
    --white: #ffffff;
}

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

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Google Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: url('https://eventbase.es/wp-content/uploads/2025/12/blue-icebergs-in-the-atlantic-ocean-in-ilulissat-i-2025-10-16-23-36-10-utc-scaled.jpg') no-repeat center center;
    background-size: cover;
    color: var(--polar-black);
    line-height: 1.6;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding: 0;
    position: relative;
    width: 100%;
    overflow-x: hidden;
}

/* iOS viewport fix */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}

/* Fixed background for desktop only */
@media (min-width: 769px) {
    body {
        background-attachment: fixed;
    }
}

/* Mobile optimization */
@media (max-width: 768px) {
    body {
        background-attachment: scroll;
        background-position: center top;
    }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    background: linear-gradient(to bottom, rgba(0,0,0,0.20), rgba(0,0,0,0.35));
    z-index: -1;
    pointer-events: none;
}

/* Ensure background covers on mobile */
@media (max-width: 768px) {
    body::before {
        position: absolute;
        min-height: 100%;
    }
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.18);
    padding: 1.5rem 2rem;
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: all 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    height: 50px;
    width: auto;
}

.header-info {
    text-align: right;
    color: var(--white);
    text-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.header-info h1 {
    font-family: 'Raleway', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.header-info .date {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem 2rem;
}

.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

/* Glass Card */
.glass-card {
    background: rgba(255, 255, 255, 0.20);
    backdrop-filter: blur(18px) saturate(180%);
    border-radius: 22px;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid rgba(255, 255, 255, 0.35);
    transition: all 200ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.card-title {
    font-family: 'Raleway', sans-serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--white);
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title::before {
    content: '';
    width: 4px;
    height: 1.75rem;
    background: rgba(255, 255, 255, 0.65);
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Form Sections */
.form-section {
    margin-bottom: 2rem;
}

.form-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-family: 'Raleway', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--white);
    text-shadow: 0 2px 6px rgba(0,0,0,0.25);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.95rem;
}

.form-label {
    display: block;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 4px rgba(0,0,0,0.2);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* Input Styles */
input[type="text"],
input[type="date"],
input[type="number"],
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.65);
    color: var(--polar-black);
    transition: all 180ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

input[type="text"]:hover,
input[type="date"]:hover,
input[type="number"]:hover,
textarea:hover {
    border-color: rgba(255, 255, 255, 0.55);
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--arctic-blue);
    box-shadow: 0 0 0 4px rgba(112, 195, 206, 0.35);
    background: rgba(255, 255, 255, 0.85);
}

textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

textarea.large {
    min-height: 150px;
}

.readonly-field {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--deep-blue);
    cursor: not-allowed;
}

/* Company Data Display */
.company-data {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.company-data p {
    margin: 0.25rem 0;
    color: var(--deep-blue);
    font-weight: 500;
}

/* Totals Panel */
.totals-panel {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    margin-top: 1rem;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.95rem;
}

.totals-row.total-row {
    border-top: 2px solid var(--polar-blue);
    margin-top: 0.5rem;
    padding-top: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--polar-blue);
}

.totals-label {
    font-weight: 500;
    color: var(--deep-blue);
}

.totals-value {
    font-weight: 600;
    color: var(--polar-blue);
    font-family: 'Raleway', sans-serif;
}

/* Payment Info */
.payment-info {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 0.9rem;
    line-height: 1.8;
}

.payment-info strong {
    color: var(--deep-blue);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

button {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-family: 'Raleway', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 180ms cubic-bezier(0.22, 0.61, 0.36, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--arctic-blue), var(--polar-blue));
    color: var(--white);
    box-shadow: 0 4px 15px rgba(40, 152, 174, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 32px rgba(40, 152, 174, 0.45);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.65);
    color: var(--polar-blue);
    border: 2px solid rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(8px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.85);
    border-color: var(--arctic-blue);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.btn-secondary:active {
    transform: translateY(0) scale(0.98);
}

.btn-download {
    background: linear-gradient(135deg, var(--deep-blue), var(--polar-blue));
    color: var(--white);
    box-shadow: 0 4px 15px rgba(16, 103, 130, 0.3);
    margin-top: 1rem;
}

.btn-download:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 32px rgba(16, 103, 130, 0.45);
}

.btn-download:active {
    transform: translateY(0) scale(0.98);
}

/* Validation Messages */
.validation-message {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

.validation-message.show {
    display: block;
}

/* Invoice Preview */
.preview-placeholder {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--deep-blue);
    opacity: 0.6;
}

.preview-placeholder svg {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Invoice Layout */
#invoicePreview {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
}

.invoice-header {
    position: relative;
}

.invoice-meta {
    text-align: right;
}

.invoice-number {
    font-family: 'Raleway', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.invoice-date {
    font-weight: 500;
}

/* Parties Section */
.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.party-block h3 {
    font-family: 'Raleway', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--polar-blue);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.party-content {
    color: var(--polar-black);
    line-height: 1.8;
    font-size: 0.95rem;
}

.party-content p {
    margin: 0.25rem 0;
}

/* Services Table */
.invoice-table {
    width: 100%;
    margin-bottom: 2rem;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
}

.invoice-table thead {
    background: linear-gradient(135deg, var(--deep-blue), var(--polar-blue));
    color: var(--white);
}

.invoice-table th {
    padding: 1rem;
    text-align: left;
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

.invoice-table th:last-child {
    text-align: right;
}

.invoice-table tbody tr {
    border-bottom: 1px solid rgba(112, 195, 206, 0.2);
}

.invoice-table tbody tr:nth-child(even) {
    background: rgba(237, 207, 93, 0.05);
}

.invoice-table tbody tr:nth-child(odd) {
    background: var(--snow-white);
}

.invoice-table td {
    padding: 1rem;
    color: var(--polar-black);
}

.invoice-table td:last-child {
    text-align: right;
    font-weight: 600;
    color: var(--deep-blue);
    font-family: 'Raleway', sans-serif;
}

/* Invoice Totals */
.invoice-totals {
    margin-left: auto;
    width: 350px;
    margin-bottom: 2rem;
}

.invoice-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
}

.invoice-totals-row.subtotal,
.invoice-totals-row.vat {
    border-bottom: 1px solid rgba(112, 195, 206, 0.2);
}

.invoice-totals-row.total {
    background: linear-gradient(135deg, rgba(112, 195, 206, 0.15), rgba(40, 152, 174, 0.15));
    border-radius: 8px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--polar-blue);
    margin-top: 0.5rem;
}

.invoice-totals-label {
    font-weight: 500;
}

.invoice-totals-value {
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
}

/* Invoice Payment */
.invoice-payment {
    background: rgba(112, 195, 206, 0.08);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border-left: 4px solid var(--polar-blue);
}

.invoice-payment h3 {
    font-family: 'Raleway', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--polar-blue);
    margin-bottom: 0.75rem;
}

.invoice-payment p {
    margin: 0.5rem 0;
    color: var(--polar-black);
    line-height: 1.8;
}

/* Invoice Footer */
.invoice-footer {
    padding-top: 2rem;
    border-top: 2px solid rgba(112, 195, 206, 0.3);
    font-size: 0.85rem;
    color: var(--deep-blue);
    line-height: 1.8;
}

.invoice-footer p {
    margin: 0.5rem 0;
}

.invoice-footer .thank-you {
    margin-top: 1rem;
    font-weight: 600;
    color: var(--polar-blue);
}

/* Client Management Section */
.client-management {
    max-width: 1400px;
    margin: 3rem auto;
    padding: 0 1.5rem 2rem;
}

.client-management-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.client-management-title {
    font-family: 'Raleway', sans-serif;
    font-size: 2rem;
    font-weight: 600;
    color: var(--white);
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.btn-add-client {
    background: linear-gradient(135deg, var(--arctic-blue), var(--polar-blue));
    color: var(--white);
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-family: 'Raleway', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 180ms cubic-bezier(0.22, 0.61, 0.36, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(40, 152, 174, 0.3);
    white-space: nowrap;
}

.btn-add-client:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 32px rgba(40, 152, 174, 0.45);
}

.btn-add-client:active {
    transform: translateY(0) scale(0.98);
}

/* Client List */
.client-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.client-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.client-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(40, 152, 174, 0.15);
}

.client-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.client-name {
    font-family: 'Raleway', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--polar-blue);
    margin-bottom: 0.25rem;
}

.client-card-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.btn-icon:hover {
    background: rgba(112, 195, 206, 0.1);
}

.btn-edit {
    color: var(--polar-blue);
}

.btn-delete {
    color: #dc2626;
}

.client-info {
    color: var(--polar-black);
    font-size: 0.95rem;
    line-height: 1.8;
}

.client-info p {
    margin: 0.25rem 0;
}

.client-info strong {
    color: var(--deep-blue);
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--deep-blue);
    opacity: 0.6;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-family: 'Raleway', sans-serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--deep-blue);
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--deep-blue);
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-close:hover {
    background: rgba(112, 195, 206, 0.1);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Select Styles */
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(112, 195, 206, 0.3);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--white);
    color: var(--polar-black);
    transition: all 0.3s ease;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--arctic-blue);
    box-shadow: 0 0 0 4px rgba(112, 195, 206, 0.1);
}

.client-select-group {
    display: flex;
    gap: 0.75rem;
    align-items: end;
}

.client-select-group > div {
    flex: 1;
}

.btn-new-client {
    padding: 0.75rem 1.25rem;
    background: var(--white);
    color: var(--polar-blue);
    border: 2px solid var(--arctic-blue);
    border-radius: 12px;
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-size: 0.9rem;
}

.btn-new-client:hover {
    background: rgba(112, 195, 206, 0.1);
    transform: translateY(-2px);
}

/* Invoice Number Control */
.invoice-number-control {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.invoice-number-control input {
    flex: 1;
}

.btn-number-control {
    width: 45px;
    padding: 0;
    background: var(--white);
    color: var(--polar-blue);
    border: 2px solid var(--arctic-blue);
    border-radius: 12px;
    font-family: 'Raleway', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-number-control:hover {
    background: rgba(112, 195, 206, 0.15);
    transform: scale(1.05);
}

.btn-number-control:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 968px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header-info {
        text-align: center;
    }
    
    .invoice-parties {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    #invoicePreview {
        padding: 1.5rem;
    }
    
    .invoice-totals {
        width: 100%;
    }
    
    .client-management-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .client-list {
        grid-template-columns: 1fr;
    }
    
    .client-select-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-new-client {
        width: 100%;
    }
    
    .invoice-number-control {
        flex-direction: row;
    }
    
    .btn-number-control {
        width: 40px;
        font-size: 1.25rem;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 1rem 1rem;
    }
    
    .glass-card {
        padding: 1.5rem;
    }
    
    .invoice-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .invoice-meta {
        text-align: left;
    }
}

/* Hidden for PDF */
.no-pdf {
    display: block;
}

/* Custom Cursor Effect */
.custom-cursor {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(112, 195, 206, 0.8);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transition: all 150ms cubic-bezier(0.22, 0.61, 0.36, 1);
    transform: translate(-50%, -50%);
}

.custom-cursor-dot {
    width: 6px;
    height: 6px;
    background: var(--arctic-blue);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    transition: all 100ms cubic-bezier(0.22, 0.61, 0.36, 1);
    transform: translate(-50%, -50%);
}

.cursor-hover {
    transform: translate(-50%, -50%) scale(1.8);
    background: rgba(112, 195, 206, 0.15);
    border-color: var(--white);
}

/* Smooth Scroll Animation */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-grid > .glass-card:nth-child(1) { 
    animation: fadeInUp 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) 0.1s forwards;
    opacity: 0;
}

.main-grid > .glass-card:nth-child(2) { 
    animation: fadeInUp 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) 0.2s forwards;
    opacity: 0;
}

.client-management .glass-card {
    animation: fadeInUp 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) 0.3s forwards;
    opacity: 0;
}

@media print {
    .no-pdf {
        display: none !important;
    }
    
    .custom-cursor,
    .custom-cursor-dot {
        display: none !important;
    }
}
