:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --secondary: #64748b;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --error: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

.background-decor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 20% 30%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(56, 189, 248, 0.1) 0%, transparent 50%);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo-image {
    max-height: 100px;
    border-radius: 0.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Cards & Glassmorphism */
.card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.75rem;
}

.section-title i {
    color: var(--accent);
}

.section-title h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Form Layout */
.grid-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

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

.full-width {
    grid-column: span 2;
}

/* Mobile specific grid stack */
@media (max-width: 640px) {
    .grid-form {
        grid-template-columns: 1fr;
    }
    .full-width {
        grid-column: span 1;
    }
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

#bitacoraForm input, 
#bitacoraForm select, 
#bitacoraForm textarea {
    text-transform: uppercase;
}

#loginForm input {
    text-transform: none !important;
}

input, select, textarea {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.2s ease;
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5);
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.autocomplete-item:hover {
    background: var(--primary);
}

.autocomplete-item .ubicacion {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Preview Gallery */
.preview-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.preview-gallery img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid var(--glass-border);
}

.remove-photo-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 10;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Details Table/List (Mobile Specific) */
.mobile-table-header {
    display: grid;
    grid-template-columns: 1fr 2fr;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

@media (max-width: 640px) {
    .mobile-table-header { display: none; }
}

.detail-row {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 1rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.detail-row:hover {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.row-header {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
}

.row-inputs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.row-inputs .form-group:last-child {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .row-inputs {
        grid-template-columns: 1fr !important;
    }
    .row-inputs .form-group {
        grid-column: span 1 !important;
    }
    .row-inputs input[type="hidden"] {
        display: none;
    }
}

/* Signature & Upload */
.signature-container {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 1rem;
    cursor: crosshair;
}

canvas {
    display: block;
    width: 100%;
    height: 200px;
}

.upload-area {
    border: 2px dashed var(--glass-border);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

.upload-placeholder i {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.preview-container img {
    max-width: 100%;
    border-radius: 0.75rem;
    margin-top: 1rem;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 1rem;
    padding: 1.25rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Responsive Table to Cards */
@media (max-width: 768px) {
    .responsive-table table, 
    .responsive-table thead, 
    .responsive-table tbody, 
    .responsive-table th, 
    .responsive-table td, 
    .responsive-table tr { 
        display: block; 
    }
    
    .responsive-table thead tr { 
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .responsive-table tr { 
        border: 1px solid var(--glass-border);
        border-radius: 1rem;
        background: var(--card-bg);
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .responsive-table td { 
        border: none;
        position: relative;
        padding-left: 50% !important; 
        text-align: right;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        padding: 0.5rem 0;
    }
    
    .responsive-table td:last-child {
        border-bottom: none;
        text-align: center;
        padding-left: 0 !important;
        margin-top: 1rem;
    }
    
    .responsive-table td:before { 
        position: absolute;
        top: 0.5rem;
        left: 0;
        width: 45%; 
        padding-right: 10px; 
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: var(--text-muted);
        content: attr(data-label);
    }
}

/* User Controls & Navigation */
.user-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.nav-btns {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-nav, .btn-logout {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    transition: all 0.2s;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-nav:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

.btn-logout:hover {
    color: var(--error);
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}

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

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    width: 100%;
    max-width: 500px;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.signature-container {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 1.5rem;
    touch-action: none; /* Crucial for mobile scroll lock on canvas */
}

.modal-footer {
    display: flex;
    gap: 1rem;
}

.signature-preview-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed var(--glass-border);
    border-radius: 1rem;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.signature-preview-box img {
    max-height: 100%;
    filter: invert(1); /* If background is dark and signature is black */
}

body.modal-open {
    overflow: hidden;
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Tablet & Mobile Grid Adjustments */
@media (max-width: 768px) {
    .grid-2-col {
        grid-template-columns: 1fr;
    }
    
    .grid-form {
        grid-template-columns: 1fr;
    }
    
    .full-width {
        grid-column: span 1;
    }
    
    .container {
        padding: 0.75rem;
    }
    
    .card {
        padding: 1.25rem;
        border-radius: 1rem;
    }
    
    .btn-primary {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }
}

.hidden { display: none; }

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 2rem;
    border-radius: 1rem;
    background: var(--primary);
    color: white;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: fadeInUp 0.5s ease-out;
}
