:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --dark: #1e293b;
    --text-main: #334155;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --bg-light: #f8fafc;
    --border: #e2e8f0;
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-light);
    color: var(--text-main);
    line-height: 1.5;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 100%;
    margin: 0;
    flex: 1;
    padding: 40px 20px 0 20px;
}

/* FORM STYLING */
.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 45px;
    border-radius: 20px;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.header-main {
    text-align: center;
    margin-bottom: 40px;
}

.header-main h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}

.header-main p {
    color: var(--text-muted);
}

form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.section-title {
    grid-column: 1 / -1;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 12px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title ion-icon {
    color: var(--primary);
    font-size: 1.3rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

input, textarea {
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    color: var(--text-dark);
    background: #fafafa;
    width: 100%;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* TOGGLE BUTTON STYLE */
.toggle-container {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f1f5f9;
    padding: 15px 20px;
    border-radius: var(--radius);
    margin-top: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1.5px solid transparent;
}

.toggle-container:hover {
    background: #e2e8f0;
}

.toggle-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.toggle-container span {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
}

/* LOGO UPLOAD */
.logo-upload-box {
    grid-column: 1 / -1;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
    display: block;
}

.logo-upload-box.hidden {
    display: none;
}

.logo-upload-box:hover {
    border-color: var(--primary);
    background: #fff;
}

#logoPreview {
    max-width: 100px;
    max-height: 100px;
    object-fit: contain;
    margin-bottom: 15px;
    display: none;
    margin-inline: auto;
}

/* DYNAMIC SERVICE ITEMS AREA */
.items-container {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.item-row {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1.5fr auto;
    gap: 12px;
    align-items: flex-end;
    animation: fadeIn 0.3s ease;
    width: 100%;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.btn-add {
    grid-column: 1 / -1;
    background: #eff6ff;
    color: var(--primary);
    border: 1px dashed var(--primary);
    padding: 12px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-add:hover {
    background: var(--primary);
    color: white;
    border-style: solid;
}

.btn-remove {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-remove:hover {
    background: #ef4444;
    color: white;
}

.btn-submit {
    grid-column: 1 / -1;
    background: var(--primary);
    color: white;
    padding: 18px;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3);
}

.btn-submit:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* MODAL STYLING */
#modalOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: flex-start;
    z-index: 1000;
    overflow-y: auto;
    padding: 40px 20px;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 900px;
    border-radius: 16px;
    position: relative;
    animation: modalIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-actions {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 15px 30px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    border-radius: 16px 16px 0 0;
}

.receipt-view {
    padding: 40px;
}

/* RECEIPT INNER STYLING */
.recibo-card {
    background: #fff;
    color: var(--text-main);
}

.recibo-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 25px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 30px;
    margin-bottom: 35px;
}

.recibo-logo {
    width: 90px;
    height: 90px;
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.recibo-logo.hidden {
    display: none;
}

.recibo-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.recibo-provider h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-dark);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.recibo-provider p {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: pre-line;
}

.recibo-brand {
    text-align: right;
}

.recibo-brand h3 {
    font-weight: 800;
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.recibo-meta { font-size: 0.85rem; color: var(--text-muted); }

.recibo-section-header {
    background: #f1f5f9;
    padding: 8px 15px;
    border-left: 4px solid var(--primary);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 20px;
    color: var(--text-dark);
}

.recibo-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.recibo-info-grid label {
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 8px;
    font-size: 0.9rem;
}

.recibo-info-grid span {
    font-weight: 700;
    color: var(--text-dark);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

thead tr { background: var(--dark); color: white; }

th, td { padding: 12px 15px; text-align: left; }

td { border-bottom: 1px solid #f1f5f9; }

.text-right { text-align: right; }

.recibo-total {
    text-align: right;
    padding: 20px;
    background: #f8fafc;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-dark);
}

.recibo-declaration {
    background: #fdfdfd;
    border: 1px dashed #e2e8f0;
    padding: 25px;
    border-radius: 10px;
    font-size: 0.95rem;
    line-height: 1.7;
    margin-top: 30px;
}

.recibo-signature {
    margin-top: 60px;
    text-align: center;
}

.signature-line {
    width: 300px;
    border-top: 2px solid var(--text-dark);
    margin: 0 auto 10px;
}

/* PRINT STYLES */
@media print {
    body * { visibility: hidden; }
    #modalOverlay, #modalOverlay * { visibility: visible; }
    #modalOverlay { position: absolute; left: 0; top: 0; background: white; padding: 0; }
    .modal-actions, .no-print { display: none !important; }
    .modal-content { box-shadow: none; border: none; width: 100%; max-width: 100%; margin: 0; }
    .receipt-view { padding: 0; }
}

/* FOOTER CTA */
.footer-cta {
    width: 100%;
    background: #0F172A;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    margin-top: 0;
}

.footer-cta-container {
    width: 100%;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
}

.footer-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
}

.footer-bottom {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

.footer-bottom p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

.footer-bottom a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.footer-bottom a:hover {
    color: white;
    text-decoration: underline;
}

.footer-text {
    color: white;
}

.footer-text h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.footer-text p {
    font-size: 0.95rem;
    opacity: 0.95;
    line-height: 1.6;
}

.footer-btn {
    background: white;
    color: var(--primary);
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.footer-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    background: #f8fafc;
}

.footer-btn ion-icon {
    font-size: 1.3rem;
}

/* TABLET AND DESKTOP */
@media (min-width: 768px) {
    .footer-text h3 {
        font-size: 1.15rem;
    }
    
    .footer-text p {
        font-size: 0.9rem;
    }
    
    .footer-btn {
        font-size: 0.9rem;
        padding: 14px 24px;
    }
}

@media (max-width: 767px) {
    .main-wrapper {
        padding: 20px 0 0 0;
    }

    .container {
        max-width: 100%;
        padding: 30px 20px;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }

    .header-main h1 {
        font-size: 1.5rem;
    }

    form { grid-template-columns: 1fr; }
    
    .item-row { 
        grid-template-columns: 1fr 1fr 42px;
        gap: 8px;
    }
    
    .item-row > .form-group:first-child {
        grid-column: 1 / -1;
    }
}
