/* Panel Web - Styles */

:root {
    --theme-primary: #0d6efd;
    --theme-secondary: #6c757d;
    --theme-navbar: #0d6efd;
    --theme-accent: #0dcaf0;
}

body {
    background-color: #f4f6f9;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Login page */
.login-container {
    max-width: 400px;
    margin: 100px auto;
}

.login-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.login-card .card-header {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-navbar));
    border-radius: 12px 12px 0 0 !important;
    padding: 30px;
    text-align: center;
}

.login-card .card-header h3 {
    color: white;
    margin: 0;
}

.login-card .card-header p {
    color: rgba(255,255,255,0.8);
    margin: 5px 0 0;
}

/* Dashboard */
.stat-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.7;
}

.stat-card.primary { border-left: 4px solid var(--theme-primary); }
.stat-card.success { border-left: 4px solid #198754; }
.stat-card.warning { border-left: 4px solid #ffc107; }
.stat-card.info { border-left: 4px solid var(--theme-accent); }
.stat-card.danger { border-left: 4px solid #dc3545; }

/* Tables */
.table-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 20px;
}

/* Status badges */
.badge-draft { background-color: #6c757d; }
.badge-assigned { background-color: #0dcaf0; }
.badge-opened { background-color: #0d6efd; }
.badge-in_progress { background-color: #fd7e14; }
.badge-signed { background-color: #198754; }
.badge-pdf_generated { background-color: #20c997; }
.badge-email_sent { background-color: #6610f2; }
.badge-completed { background-color: #198754; }
.badge-cancelled { background-color: #dc3545; }

/* Tablet status */
.tablet-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: all 0.3s;
}

.tablet-card.idle { border-top: 4px solid #198754; }
.tablet-card.assigned { border-top: 4px solid #fd7e14; }
.tablet-card.active { border-top: 4px solid #0d6efd; }
.tablet-card.offline { border-top: 4px solid #dc3545; }

.tablet-status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.tablet-status-indicator.idle { background-color: #198754; }
.tablet-status-indicator.assigned { background-color: #fd7e14; }
.tablet-status-indicator.active { background-color: #0d6efd; }
.tablet-status-indicator.offline { background-color: #dc3545; }

/* Responsive fixes */
@media (max-width: 991px) {
    .navbar .navbar-collapse {
        max-height: 80vh;
        overflow-y: auto;
    }
    #global-search-form {
        width: 100%;
        margin: 8px 0;
    }
    #global-search-input {
        min-width: 100% !important;
    }
    #search-results-dropdown {
        width: 100% !important;
        left: 0 !important;
        right: auto !important;
    }
}

@media (max-width: 768px) {
    .stat-card {
        margin-bottom: 15px;
    }
    .stat-card .stat-icon {
        font-size: 1.8rem;
    }
    .stat-card .fs-3 {
        font-size: 1.5rem !important;
    }
    .table-container {
        padding: 12px;
        border-radius: 8px;
    }
    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }
    h4.mb-4 {
        font-size: 1.2rem;
    }
    /* Stack action buttons vertically on mobile */
    .btn-group-responsive {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    /* Make modals full-screen on small devices */
    .modal-dialog {
        margin: 0.5rem;
    }
    .modal-xl, .modal-lg {
        max-width: calc(100% - 1rem);
    }
    /* Hide less important table columns on mobile */
    .hide-mobile {
        display: none !important;
    }
    /* Pagination smaller on mobile */
    .pagination .page-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .login-container {
        margin: 40px auto;
        padding: 0 15px;
    }
    .login-card .card-header {
        padding: 20px;
    }
    .navbar-brand {
        font-size: 0.9rem;
    }
    /* Cards need to be compact */
    .card.p-3 {
        padding: 0.75rem !important;
    }
}

/* Events timeline */
.event-timeline {
    list-style: none;
    padding: 0;
}

.event-timeline li {
    padding: 8px 15px;
    border-left: 3px solid #dee2e6;
    margin-bottom: 5px;
    position: relative;
}

.event-timeline li::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--theme-primary);
    position: absolute;
    left: -7px;
    top: 12px;
}

.event-timeline .event-time {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    display: none;
}

.loading-overlay.active {
    display: flex;
}

/* Real-time activity toast notifications (Feature 4) */
.realtime-toast {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.realtime-toast .toast-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-left: 4px solid #198754;
    animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    transition: opacity 0.3s, transform 0.3s;
}
.realtime-toast .toast-item:hover {
    transform: translateX(-4px);
}
.realtime-toast .toast-item.toast-exit {
    opacity: 0;
    transform: translateX(100%);
}
.realtime-toast .toast-item .toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}
.realtime-toast .toast-item .toast-body {
    flex: 1;
    min-width: 0;
}
.realtime-toast .toast-item .toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
}
.realtime-toast .toast-item .toast-msg {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
}
.realtime-toast .toast-item .toast-time {
    font-size: 0.7rem;
    color: #999;
    margin-top: 4px;
}
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* Pulsing tablet indicator (Feature 4) */
.tablet-status-indicator.active {
    animation: tabletPulse 1.5s ease-in-out infinite;
}
.tablet-status-indicator.assigned {
    animation: tabletPulseOrange 2s ease-in-out infinite;
}
@keyframes tabletPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13,110,253,0.6); }
    50% { box-shadow: 0 0 0 8px rgba(13,110,253,0); }
}
@keyframes tabletPulseOrange {
    0%, 100% { box-shadow: 0 0 0 0 rgba(253,126,20,0.5); }
    50% { box-shadow: 0 0 0 6px rgba(253,126,20,0); }
}

/* Quill Editor in modal */
#contract-body-editor-container .ql-container {
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.95rem;
}

#contract-body-editor-container .ql-editor {
    min-height: 280px;
}
