/* ============================================
   CNH Digital — Admin Panel CSS
   Estilo AdminLTE Dark Sidebar
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1a1a2e;
    --sidebar-dark: #12121f;
    --sidebar-hover: #252545;
    --sidebar-active: #0d6efd;
    --topbar-height: 60px;
    --primary: #0d6efd;
    --primary-dark: #0b5ed7;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #0dcaf0;
    --text: #212529;
    --text-muted: #6c757d;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --border: #dee2e6;
    --shadow: 0 0 15px rgba(0,0,0,.05);
    --radius: 8px;
}

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

body {
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ============ LOGIN PAGE ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-wrapper { width: 100%; max-width: 420px; padding: 20px; }

.login-box { text-align: center; }

.login-logo {
    margin-bottom: 32px;
    color: #fff;
}

.logo-icon {
    width: 80px; height: 80px;
    margin: 0 auto 16px;
    background: rgba(255,255,255,.1);
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    color: var(--primary);
    border: 1px solid rgba(255,255,255,.15);
    backdrop-filter: blur(10px);
}

.login-logo h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.login-logo p { font-size: 14px; opacity: .6; margin-top: 4px; }

.login-card {
    background: rgba(255,255,255,.07);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 16px;
    padding: 32px;
    text-align: left;
}

.login-card .card-header {
    font-size: 14px;
    color: rgba(255,255,255,.6);
    margin-bottom: 24px;
}

.login-card .form-group { margin-bottom: 20px; }
.login-card label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,.8);
    margin-bottom: 8px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 14px; top: 50%; transform: translateY(-50%);
    color: rgba(255,255,255,.3);
    font-size: 14px;
}

.input-icon input {
    width: 100%;
    padding: 14px 14px 14px 42px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    font-family: inherit;
    transition: all .2s;
}

.input-icon input::placeholder { color: rgba(255,255,255,.25); }
.input-icon input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255,255,255,.1);
    box-shadow: 0 0 0 3px rgba(13,110,253,.15);
}

.alert-error {
    background: rgba(220,53,69,.15);
    border: 1px solid rgba(220,53,69,.3);
    color: #ff6b6b;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
    letter-spacing: .5px;
}
.btn-login:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }

.login-footer {
    margin-top: 32px;
    color: rgba(255,255,255,.25);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    z-index: 1000;
    display: flex; flex-direction: column;
    transition: transform .3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
}

.sidebar-brand {
    padding: 20px 20px;
    display: flex; align-items: center; gap: 12px;
    background: var(--sidebar-dark);
    color: #fff;
    font-size: 20px; font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand i { color: var(--primary); font-size: 24px; }

.sidebar-user {
    padding: 20px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.user-avatar {
    width: 44px; height: 44px;
    background: var(--sidebar-active);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px;
}
.user-info { display: flex; flex-direction: column; }
.user-name { color: #fff; font-weight: 600; font-size: 14px; }
.user-role { color: rgba(255,255,255,.4); font-size: 12px; }

.sidebar-nav {
    flex: 1; padding: 12px 10px; overflow-y: auto;
}

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    color: rgba(255,255,255,.6);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px; font-weight: 400;
    transition: all .15s;
    margin-bottom: 2px;
}
.nav-item i { width: 20px; text-align: center; font-size: 15px; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
    background: var(--sidebar-active);
    color: #fff; font-weight: 600;
    box-shadow: 0 4px 12px rgba(13,110,253,.3);
}
.nav-logout:hover { background: rgba(220,53,69,.2); color: #ff6b6b; }

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: 8px 16px;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.06);
    color: rgba(255,255,255,.2);
    font-size: 11px;
    text-align: center;
}

/* ============ TOPBAR ============ */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.topbar-toggle {
    background: none; border: none;
    font-size: 20px; color: var(--text-muted);
    cursor: pointer; padding: 8px;
    border-radius: 8px;
    transition: background .2s;
}
.topbar-toggle:hover { background: var(--bg); }

.topbar-title { flex: 1; font-size: 18px; font-weight: 600; }

.server-status {
    font-size: 13px; color: var(--success);
    display: flex; align-items: center; gap: 6px;
}
.server-status i { font-size: 8px; }

/* ============ MAIN CONTENT ============ */
.dashboard-page .main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left .3s ease;
    min-height: 100vh;
}

.content-wrapper { padding: 24px; }

/* ============ STATS CARDS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid transparent;
    transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }

.stat-blue { border-left-color: var(--primary); }
.stat-green { border-left-color: var(--success); }
.stat-yellow { border-left-color: var(--warning); }
.stat-red { border-left-color: var(--danger); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.stat-blue .stat-icon { background: rgba(13,110,253,.1); color: var(--primary); }
.stat-green .stat-icon { background: rgba(25,135,84,.1); color: var(--success); }
.stat-yellow .stat-icon { background: rgba(255,193,7,.1); color: #d4a100; }
.stat-red .stat-icon { background: rgba(220,53,69,.1); color: var(--danger); }

.stat-value { font-size: 28px; font-weight: 700; display: block; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--text-muted); }

/* ============ CARDS ============ */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
}
.card-header h3 {
    font-size: 16px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.card-header h3 i { color: var(--primary); }

.header-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.card-body { padding: 20px; }

/* ============ TABLE ============ */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: #f8f9fe; }

.empty-state {
    text-align: center;
    padding: 40px !important;
    color: var(--text-muted);
    font-size: 14px;
}

/* ============ BADGES ============ */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.badge-green { background: rgba(25,135,84,.1); color: var(--success); }
.badge-red { background: rgba(220,53,69,.1); color: var(--danger); }
.badge-blue { background: rgba(13,110,253,.1); color: var(--primary); }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    border: none; border-radius: 6px;
    font-size: 14px; font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #157347; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #bb2d3b; }
.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: #e0a800; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5c636a; }

.btn-icon {
    width: 34px; height: 34px;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
    font-size: 14px;
}

/* ============ SEARCH ============ */
.search-box {
    position: relative;
}
.search-box i {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted); font-size: 14px;
}
.search-box input {
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    width: 280px;
    transition: all .2s;
}
.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,.1);
}

/* ============ FORM ============ */
.form-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f0f0f0;
}
.form-section:last-child { border-bottom: none; }

.form-section h4 {
    font-size: 15px; font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}

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

.form-group { display: flex; flex-direction: column; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
    font-size: 12px; font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-group input,
.form-group select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: all .2s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,.1);
}

.form-actions {
    display: flex; gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* ============ INFO GRID ============ */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}
.info-item {
    background: var(--bg);
    padding: 14px 18px;
    border-radius: 8px;
}
.info-item label {
    display: block;
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}
.info-item span { font-size: 15px; font-weight: 600; }

.endpoints-list { display: flex; flex-direction: column; gap: 8px; }
.endpoint {
    padding: 10px 14px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 14px;
    display: flex; align-items: center; gap: 10px;
}
.endpoint code {
    background: var(--primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    min-width: 52px;
    text-align: center;
}

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}
.modal-box {
    background: #fff;
    border-radius: 16px;
    width: 440px;
    max-width: 90vw;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header {
    padding: 20px 24px;
    display: flex; align-items: center; gap: 12px;
    font-size: 20px;
}
.modal-header h3 { font-size: 18px; }
.modal-danger { background: rgba(220,53,69,.08); color: var(--danger); }

.modal-body { padding: 20px 24px; }
.modal-body .text-muted { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.modal-footer {
    padding: 16px 24px;
    display: flex; gap: 10px; justify-content: flex-end;
    border-top: 1px solid var(--border);
}

/* ============ TOAST ============ */
.toast-container {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 3000;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    padding: 14px 20px;
    border-radius: 10px;
    color: #fff;
    font-size: 14px; font-weight: 500;
    display: flex; align-items: center; gap: 10px;
    min-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    animation: toastIn .3s ease;
}
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

/* ============ IMAGE UPLOAD ============ */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 4px;
    cursor: pointer;
    transition: all .2s;
    background: #fafbfc;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.upload-area:hover {
    border-color: var(--primary);
    background: rgba(13,110,253,.03);
}
.upload-area.drag-over {
    border-color: var(--primary);
    background: rgba(13,110,253,.08);
    transform: scale(1.01);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    padding: 20px;
}
.upload-placeholder i {
    font-size: 36px;
    color: var(--border);
}
.upload-placeholder span {
    font-size: 14px;
    font-weight: 500;
}
.upload-placeholder small {
    font-size: 11px;
    opacity: .7;
}

.upload-preview {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    gap: 8px;
}
.upload-preview img {
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid #eee;
    background: repeating-conic-gradient(#f0f0f0 0% 25%, transparent 0% 50%) 50% / 16px 16px;
}
.upload-info {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.upload-info span {
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
}
.upload-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 12px !important;
}

/* ============ SIGNATURE PAD ============ */
.signature-pad-wrapper {
    border: 2px dashed var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    transition: border-color .2s;
}
.signature-pad-wrapper:hover {
    border-color: var(--primary);
}

#signatureCanvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
    background: #fff;
    touch-action: none;
}

.signature-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg);
    border-top: 1px solid #eee;
    gap: 12px;
}

.signature-tools {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pen-size-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
}
.pen-size-label input[type="range"] {
    width: 80px;
    accent-color: var(--primary);
}

.pen-colors {
    display: flex;
    gap: 6px;
    align-items: center;
}
.pen-color {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all .15s;
    display: inline-block;
}
.pen-color:hover {
    transform: scale(1.15);
}
.pen-color.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(13,110,253,.3);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar-open .sidebar { transform: translateX(0); }
    .dashboard-page .main-content { margin-left: 0; }
    .search-box input { width: 200px; }
    .form-row { grid-template-columns: 1fr; }
}
