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

:root {
    /* Color Palette */
    --bg-main: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --border-color: rgba(226, 232, 240, 0.8);
    
    /* Brand Colors */
    --primary: hsl(224, 76%, 48%);
    --primary-hover: hsl(224, 76%, 40%);
    --primary-light: hsl(224, 100%, 96%);
    --primary-glow: rgba(37, 99, 235, 0.12);
    
    /* State colors */
    --color-pending: hsl(38, 92%, 50%);      /* Amber */
    --bg-pending: hsl(38, 100%, 96%);
    
    --color-preapproved: hsl(199, 89%, 48%);  /* Sky blue */
    --bg-preapproved: hsl(199, 100%, 96%);

    --color-rebound: hsl(350, 89%, 60%);      /* Coral/Red */
    --bg-rebound: hsl(350, 100%, 97%);

    --color-resolved: hsl(142, 70%, 45%);    /* Emerald/Green */
    --bg-resolved: hsl(142, 100%, 96%);
    
    /* Texts */
    --text-main: #0f172a;       /* Slate 900 */
    --text-muted: #64748b;      /* Slate 500 */
    --text-heading: #1e293b;    /* Slate 800 */
    
    /* Glassmorphism and Shadows */
    --glass-blur: blur(16px);
    --glass-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.04), 0 8px 16px -6px rgba(15, 23, 42, 0.03);
}

/* Reset and Globals */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

body {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Layout Wrapper */
.app-main {
    padding: 1.5rem 1.75rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Login layout body context */
.kiosco-body {
    background: linear-gradient(135deg, hsl(210, 40%, 94%) 0%, hsl(224, 76%, 92%) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* Glassmorphism Card (Base Container) */
.despachos-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: box-shadow 0.3s ease;
}

.despachos-card:hover {
    box-shadow: 0 20px 35px -10px rgba(15, 23, 42, 0.08);
}

/* Headings */
.gradient-text {
    background: linear-gradient(135deg, hsl(224, 76%, 20%) 0%, hsl(224, 76%, 45%) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

/* KPI Cards Layout - FIXED SIZING */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    display: flex;
    flex-direction: row !important; /* Force side-by-side */
    justify-content: space-between !important;
    align-items: center;
    padding: 1.5rem;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--glass-shadow);
    margin-bottom: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 30px -10px rgba(15, 23, 42, 0.1);
}

.kpi-card-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.kpi-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 1rem;
    transition: transform 0.25s ease;
}

.kpi-card:hover .kpi-icon-wrapper {
    transform: scale(1.1) rotate(5deg);
}

/* Standardized Icon styles inside wrappers */
.kpi-icon {
    width: 24px !important;
    height: 24px !important;
    display: block;
}

/* KPI Card Left Borders & Colors */
.kpi-card-total { border-left: 5px solid var(--primary); }
.bg-total-light { background-color: var(--primary-light); }
.color-total { color: var(--primary); }

.kpi-card-pending { border-left: 5px solid var(--color-pending); }
.bg-pending-light { background-color: var(--bg-pending); }
.color-pending { color: var(--color-pending); }

.kpi-card-preapproved { border-left: 5px solid var(--color-preapproved); }
.bg-preapproved-light { background-color: var(--bg-preapproved); }
.color-preapproved { color: var(--color-preapproved); }

.kpi-card-resolved { border-left: 5px solid var(--color-resolved); }
.bg-resolved-light { background-color: var(--bg-resolved); }
.color-resolved { color: var(--color-resolved); }

/* Forms Structure */
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group, .form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label, .form-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-heading);
}

.required::after {
    content: " *";
    color: var(--color-rebound);
}

/* Fields Styling */
.form-group input,
.form-group select,
.form-group textarea,
.form-field input,
.form-field select,
.form-field textarea {
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-main);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    font-family: inherit;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
    outline: none;
}

.form-group select, .form-field select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2.5rem;
}

.form-group textarea, .form-field textarea {
    resize: vertical;
    min-height: 90px;
}

/* Input Disabled Styling */
.input-disabled, input:disabled, select:disabled, textarea:disabled {
    background: #f1f5f9 !important;
    color: var(--text-muted) !important;
    cursor: not-allowed !important;
    border-color: var(--border-color) !important;
}

/* Radio buttons Group styling */
.radio-group-inline {
    display: flex;
    gap: 1.5rem;
    padding: 0.5rem 0;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-heading);
}

.radio-label input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Modern File Uploads */
.file-upload-area {
    position: relative;
}

.file-upload-area input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-upload-label:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-text {
    font-weight: 600;
    color: var(--text-heading);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* File Previews */
.preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.preview-item {
    position: relative;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.preview-item img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 6px;
}

.file-icon {
    width: 100%;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    border-radius: 6px;
    color: #ffffff;
}

.pdf-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }
.doc-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.preview-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    word-break: break-word;
    max-width: 100%;
}

.remove-file {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: #ffffff;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.remove-file:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Premium Buttons Styling */
.btn-submit-premium {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #ffffff;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transition: all 0.25s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-submit-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.35);
}

.btn-submit {
    padding: 0.75rem 2rem;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.btn-submit:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.3);
}

.btn-cancel {
    background: #ffffff;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
    text-align: center;
    cursor: pointer;
}

.btn-cancel:hover {
    background: #f8fafc;
    color: var(--text-main);
    border-color: #cbd5e1;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: #ffffff;
    color: var(--text-heading);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    cursor: pointer;
    display: inline-block;
    text-align: center;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-excel {
    background: #10b981;
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-excel:hover {
    background: #059669;
    box-shadow: 0 8px 16px rgba(16, 185, 129, 0.3);
    transform: translateY(-2px);
}

/* Floating Navigation Header */
.navbar-simple {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 30px rgba(15, 23, 42, 0.03);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e3a8a;
    letter-spacing: -0.5px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-logout-nav {
    padding: 0.5rem 1rem;
    background: #fee2e2;
    color: #dc2626;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 8px;
    border: 1px solid #fca5a5;
    transition: all 0.2s ease;
}

.btn-logout-nav:hover {
    background: #fecaca;
    border-color: #f87171;
}

/* Document Header Forms Panel */
.form-header-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    margin-bottom: 2rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.form-header-top {
    display: flex;
    gap: 1.5rem;
    padding: 1.75rem 2rem;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
}

.form-logo {
    flex-shrink: 0;
}

.logo-img {
    width: 65px;
    height: 65px;
    object-fit: contain;
}

.form-header-content {
    flex: 1;
}

.form-main-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.form-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-metadata span strong {
    font-weight: 700;
    color: var(--text-heading);
}

.form-section-label {
    background: #f8fafc;
    padding: 0.75rem 2rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-heading);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-top: 1px solid #f1f5f9;
}

/* Redesigned Form Container */
.form-container {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--border-color);
    margin: 0 auto;
    overflow: hidden;
}

.form-section {
    padding: 2.25rem;
    border-bottom: 1px solid #f1f5f9;
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-actions {
    padding: 1.5rem 2.25rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Premium Structured Tables */
.table-premium {
    width: 100%;
    border-collapse: collapse;
}

.table-premium th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    padding: 1.1rem 1rem;
    border-bottom: 2px solid var(--border-color);
}

.table-premium td {
    padding: 1.1rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
    color: var(--text-main);
    vertical-align: middle;
}

.tr-hover {
    transition: background-color 0.2s ease;
}

.tr-hover:hover {
    background-color: hsla(224, 76%, 48%, 0.02);
}

/* Badges for status markers */
.badge-id {
    font-family: monospace;
    font-size: 0.9rem;
    padding: 0.15rem 0.4rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
}

.badge-state {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

.badge-pending {
    background: var(--bg-pending);
    color: var(--color-pending);
    border: 1px solid hsla(38, 92%, 50%, 0.25);
}

.badge-preapproved {
    background: var(--bg-preapproved);
    color: var(--color-preapproved);
    border: 1px solid hsla(199, 89%, 48%, 0.25);
}

.badge-rebound {
    background: var(--bg-rebound);
    color: var(--color-rebound);
    border: 1px solid hsla(350, 89%, 60%, 0.25);
}

.badge-resolved {
    background: var(--bg-resolved);
    color: var(--color-resolved);
    border: 1px solid hsla(142, 70%, 45%, 0.25);
}

/* Modal Overlay and Window Redesign */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease;
    padding: 1.5rem;
}

.modal-content {
    background: #ffffff;
    border-radius: 20px;
    padding: 2.25rem;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    position: relative;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

/* Custom Success Icon checkmark animation */
.success-icon-container {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem auto;
}

.checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 2;
    stroke: var(--color-resolved);
    stroke-miterlimit: 10;
    box-shadow: inset 0 0 0 var(--color-resolved);
    animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out 0s forwards;
}

.checkmark__circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: var(--color-resolved);
    fill: none;
    animation: stroke .6s cubic-bezier(.65,0,.45,1) forwards;
}

.checkmark__check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke: #fff;
    animation: stroke .3s cubic-bezier(.65,0,.45,1) .8s forwards;
}

@keyframes stroke { 100% { stroke-dashoffset: 0; } }
@keyframes scale { 0%, 100% { transform: none; } 50% { transform: scale3d(1.1, 1.1, 1); } }
@keyframes fill { 100% { box-shadow: inset 0 0 0 40px var(--color-resolved); } }

/* Alerts styling */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.alert-error {
    background: var(--bg-rebound);
    border: 1px solid hsla(350, 89%, 60%, 0.2);
    color: var(--color-rebound);
}

.alert-success {
    background: var(--bg-resolved);
    border: 1px solid hsla(142, 70%, 45%, 0.2);
    color: var(--color-resolved);
}

/* Responsive Overrides */
@media (max-width: 1024px) {
    .app-main {
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
        gap: 1rem;
    }
    
    .nav-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .nav-link, .btn-logout-nav {
        width: 100%;
        text-align: center;
    }
    
    .form-header-top {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }
    
    .logo-img {
        width: 55px;
        height: 55px;
    }
    
    .form-main-title {
        font-size: 1.05rem;
    }
    
    .form-metadata {
        justify-content: center;
        font-size: 0.75rem;
        gap: 0.75rem;
    }
    
    .form-section {
        padding: 1.5rem;
    }
    
    .form-actions {
        padding: 1.25rem 1.5rem;
        flex-direction: column;
    }
    
    .form-actions button, .form-actions a {
        width: 100%;
    }
}
