/* ========================================
   CMS Driver Portal - Styles
   ======================================== */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #121212;
    --bg-card: rgba(25, 25, 40, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.03);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --border-color: rgba(255, 255, 255, 0.08);

    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
}

.hidden {
    display: none !important;
}

/* Pages */
.page {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Auth */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: var(--radius-xl);
}

.logo-section {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.logo-icon.small {
    font-size: 1.5rem;
}

.logo-section h1 {
    font-size: 1.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-section .subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.form-section h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.input-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Password Toggle */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    flex: 1;
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
    font-size: 1.1rem;
}

.password-toggle:hover {
    color: var(--text-primary);
}

.password-toggle .eye-icon {
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle .eye-icon img {
    width: 20px;
    height: 20px;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.password-toggle:hover .eye-icon img {
    opacity: 0.8;
}

.password-toggle.active .eye-icon img {
    opacity: 1;
}

.form-footer {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-round {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    font-size: 1.5rem;
    padding: 0;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
}

.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.85rem;
    text-align: center;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-title h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.header-title p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Actions (Dashboard) */
.main-actions {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.actions-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 400px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    border-radius: var(--radius-xl);
    background: var(--accent-gradient);
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    min-height: 120px;
}

.action-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(99, 102, 241, 0.3);
}

.action-btn:active {
    transform: translateY(-2px);
}

.action-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.action-text {
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
}

/* Extrato Page */
.extrato-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

/* Summary Cards Row */
.summary-cards-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .summary-cards-row {
        grid-template-columns: repeat(5, 1fr);
    }
}

.summary-card-sm {
    padding: 1rem;
    border-radius: var(--radius-lg);
    text-align: center;
}

.summary-card-sm .card-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.summary-card-sm .card-value {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-card-sm.highlight {
    background: var(--accent-gradient);
    border: none;
}

.summary-card-sm.highlight .card-label {
    color: rgba(255, 255, 255, 0.8);
}

/* Card type variants */
.summary-card-sm.card-received .card-value {
    color: var(--success);
}

.summary-card-sm.card-negative .card-value {
    color: var(--error);
}

/* Extrato Sections */
.extrato-section {
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.extrato-section h2 {
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table th {
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 1.5rem;
}

.data-table .empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 1.5rem;
}

.value-positive {
    color: var(--success);
}

.value-negative {
    color: var(--error);
}

.text-muted {
    color: var(--text-muted);
}

.btn-view {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    border-radius: var(--radius-sm);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-xl);
    animation: modalIn 0.3s ease;
}

.camera-modal {
    max-width: 100%;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    padding: 1.5rem;
}

.camera-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #000;
    position: relative;
}

.camera-body video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-body .photo-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.camera-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
}

.camera-type-select {
    display: flex;
    gap: 0.5rem;
}

.type-btn {
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.type-btn.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

.camera-actions {
    display: flex;
    gap: 1rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9rem;
    z-index: 2000;
    animation: toastIn 0.3s ease;
}

.toast.success {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.2);
}

.toast.error {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.2);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .action-btn {
        min-height: 100px;
        padding: 1.5rem 1rem;
    }

    .action-text {
        font-size: 1.1rem;
    }

    .summary-card-sm .card-value {
        font-size: 0.85rem;
    }

    .data-table {
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.35rem;
    }
}

/* Waiting for Authorization Page */
.waiting-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.waiting-card {
    max-width: 450px;
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    text-align: center;
}

.waiting-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.waiting-card h2 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.waiting-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.waiting-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.waiting-info .info-icon {
    font-size: 1.2rem;
}

/* Additional Plates */
.additional-plate-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.additional-plate-row .additional-plate-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    text-transform: uppercase;
}

.additional-plate-row .additional-plate-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.btn-remove-plate {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
    border: 1px solid var(--error);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-remove-plate:hover {
    background: rgba(239, 68, 68, 0.3);
}

#additionalPlatesContainer {
    margin-bottom: 1rem;
}

#additionalPlatesContainer label {
    margin-bottom: 0.5rem;
}

#addPlateBtn {
    margin-top: 0.5rem;
}

/* Plate Selection in Camera Modals */
.plate-select-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    width: 100%;
}

.plate-select-container label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.plate-select {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    min-width: 200px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.plate-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.plate-select option {
    background: #1a1a2e;
    color: var(--text-primary);
}

/* Password Recovery Forms */
.form-title {
    text-align: center;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.code-input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    font-weight: 600;
}

/* ========================================
   PDF Export Print Mode
   ======================================== */
.pdf-print-mode {
    background: #ffffff !important;
}

.pdf-print-mode,
.pdf-print-mode * {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
}

.pdf-print-mode .glass,
.pdf-print-mode .extrato-section,
.pdf-print-mode .summary-card-sm {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
}

.pdf-print-mode .data-table th,
.pdf-print-mode .data-table td {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
}

.pdf-print-mode .data-table th {
    background: #f0f0f0 !important;
}

.pdf-print-mode .value-positive,
.pdf-print-mode .value-negative {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
}

.pdf-print-mode .summary-card-sm.highlight {
    background: #f0f0f0 !important;
}

/* ========================================
   Signup Plates Form
   ======================================== */
.signup-plate-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.signup-plate-row .signup-plate-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    text-transform: uppercase;
}

.signup-plate-row .signup-plate-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

#signupPlatesContainer {
    margin-bottom: 1rem;
}

#signupPlatesList {
    margin-bottom: 0.5rem;
}

/* ========================================
   Plates Management Page
   ======================================== */
.plates-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.plates-section {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.plates-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.plates-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.plates-list {
    margin-bottom: 2rem;
}

.plates-list .loading,
.plates-list .empty-plates,
.plates-list .error {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-plates {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
}

.plate-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-md);
}

.plate-number {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.add-plate-form {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.input-row {
    display: flex;
    gap: 0.75rem;
}

.input-row input {
    flex: 1;
}

.input-row .btn {
    white-space: nowrap;
}

@media (max-width: 480px) {
    .plates-content {
        padding: 1rem;
    }

    .plates-section {
        padding: 1rem;
    }

    .plate-item {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .input-row {
        flex-direction: column;
    }

    .input-row .btn {
        width: 100%;
    }
}