/* style.css */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Auth / Login */
.login-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 400px;
    margin: 4rem auto;
}

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

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.875rem;
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--background);
}

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

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

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; /* Ensure table doesn't get too squished on mobile */
}

th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

/* Invoice Creation */
.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 40px;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: end;
}

@media (max-width: 600px) {
    .item-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
    }
}

/* Invoice View */
#invoice {
    background: white;
    padding: 3rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
    overflow: visible; /* Crucial for html2canvas capture */
}

@media (max-width: 600px) {
    #invoice {
        padding: 1.5rem;
    }
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3rem;
}

.company-info h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.company-info p, .customer-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

.invoice-meta h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.customer-section {
    margin-bottom: 2rem;
}

.invoice-table {
    width: 100%;
    margin-bottom: 2rem;
}

.invoice-table th {
    background: #f8fafc;
    color: var(--text-main);
}

.total-section {
    display: flex;
    justify-content: flex-end;
}

.total-box {
    width: 200px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.total-row.grand-total {
    border-top: 2px solid var(--primary-color);
    font-weight: bold;
    font-size: 1.125rem;
    color: var(--primary-color);
}

.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    .actions, .btn, .header {
        display: none !important;
    }
    #invoice {
        box-shadow: none;
        padding: 0;
        margin: 0;
        width: 100%;
    }
    .container {
        padding: 0;
        margin: 0;
        max-width: none;
    }
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s;
}

.status-paid {
    background-color: #dcfce7;
    color: #166534;
}

.status-paid:hover {
    background-color: #bbf7d0;
}

.status-unpaid {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-unpaid:hover {
    background-color: #fecaca;
}

/* Watermark */
#invoice {
    position: relative;
    overflow: hidden; /* Ensure watermark stays within bounds */
}

.watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    opacity: 0.05;
    z-index: 0;
    pointer-events: none;
    user-select: none;
    width: 60%;
    max-width: 400px;
}

.invoice-header, .customer-section, .table-responsive, .total-section, .invoice-table {
    position: relative;
    z-index: 1; /* Content above watermark */
}
