/**
 * Unified Document Tracker Styles
 * Beautiful timeline-based tracking system
 * @version 1.0.0
 *
 * SCOPED TO: #document-tracker-tab only
 * These styles will NOT affect other tabs or the main site
 */

/* ========================================
   COLOR PALETTE (Scoped to Document Tracker)
   ======================================== */
#document-tracker-tab {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --info-color: #3b82f6;
    --info-light: #dbeafe;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;

    --border-color: #e5e7eb;
    --border-dark: #d1d5db;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
}

/* ========================================
   TRACKING TIMELINE COMPONENT
   ======================================== */

.tracking-timeline {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    background: var(--bg-primary);
}

/* Timeline Header */
.timeline-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2rem;
    border-radius: var(--radius-xl);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.timeline-header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.timeline-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
    min-width: 250px;
}

.timeline-tracking-number {
    font-size: 1.125rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.timeline-header-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.timeline-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-label {
    font-size: 0.875rem;
    opacity: 0.9;
    font-weight: 500;
}

.meta-value {
    font-size: 1rem;
    font-weight: 600;
}

.completion-date {
    color: #86efac;
}

/* Timeline Location Card */
.timeline-location-card {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.location-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.location-info {
    flex: 1;
}

.location-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.location-department {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.location-physical {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.location-icon-small {
    font-size: 1.125rem;
}

.location-stage {
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    display: inline-block;
    margin-top: 0.5rem;
}

.location-status {
    flex-shrink: 0;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1rem;
}

.status-completed {
    background: var(--success-light);
    color: #047857;
    border: 2px solid var(--success-color);
}

.status-in-progress {
    background: var(--info-light);
    color: #1e40af;
    border: 2px solid var(--primary-color);
}

.status-icon {
    font-size: 1.25rem;
}

/* Progress Bar */
.timeline-progress-bar {
    margin-bottom: 3rem;
}

.progress-bar-container {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--info-color) 100%);
    border-radius: 999px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}

.progress-text {
    text-align: center;
    margin-top: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Timeline Stages */
.timeline-stages {
    position: relative;
    margin-bottom: 3rem;
}

.timeline-stage {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    position: relative;
}

.stage-connector {
    position: absolute;
    left: 2rem;
    top: 3rem;
    bottom: -2rem;
    width: 3px;
    background: var(--border-color);
}

.timeline-stage:last-child .stage-connector {
    display: none;
}

.stage-connector.connector-first {
    top: 2rem;
}

.stage-marker {
    position: relative;
    flex-shrink: 0;
    width: 4rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.stage-icon {
    position: absolute;
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    transition: all 0.3s ease;
}

.stage-number {
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    border: 2px solid var(--bg-primary);
}

/* Stage States */
.stage-completed .stage-icon {
    background: var(--success-color);
    color: white;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.stage-completed .stage-connector {
    background: var(--success-color);
}

.stage-current .stage-icon {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.stage-pending .stage-icon {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 3px solid var(--border-color);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
    }
    50% {
        box-shadow: 0 0 30px rgba(37, 99, 235, 0.6);
    }
}

/* Stage Content */
.stage-content {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.stage-content:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-dark);
}

.stage-completed .stage-content {
    background: var(--success-light);
    border-color: #86efac;
}

.stage-current .stage-content {
    background: var(--primary-light);
    border-color: #93c5fd;
    border-width: 2px;
}

.stage-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.stage-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.stage-status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.stage-completed .stage-status-badge {
    background: var(--success-color);
    color: white;
}

.stage-current .stage-status-badge {
    background: var(--primary-color);
    color: white;
}

.stage-pending .stage-status-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.stage-department,
.stage-officer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.department-icon,
.officer-icon,
.notes-icon {
    font-size: 1.125rem;
}

.stage-dates {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.stage-date {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.date-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.date-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.stage-notes {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.5rem;
}

.stage-actions {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
}

.actions-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.actions-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.actions-list li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.actions-list li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: 700;
}

/* Recent Activity */
.timeline-activity {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-top: 3rem;
    box-shadow: var(--shadow-md);
}

.activity-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1.5rem 0;
}

.activity-list {
    position: relative;
}

.activity-item {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.activity-item:last-child {
    margin-bottom: 0;
}

.activity-item:not(:last-child):after {
    content: "";
    position: absolute;
    left: 0.5rem;
    top: 2rem;
    bottom: -1.5rem;
    width: 2px;
    background: var(--border-color);
}

.activity-marker {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--primary-color);
    flex-shrink: 0;
    margin-top: 0.25rem;
    position: relative;
    z-index: 2;
    box-shadow: 0 0 0 4px var(--bg-secondary);
}

.activity-item-latest .activity-marker {
    width: 1.25rem;
    height: 1.25rem;
    background: var(--success-color);
    box-shadow: 0 0 0 4px var(--bg-secondary), 0 0 10px rgba(16, 185, 129, 0.4);
}

.activity-content {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.activity-action {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.activity-time {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.activity-details {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.activity-footer {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
}

.activity-officer {
    color: var(--text-secondary);
    font-weight: 500;
}

.activity-officer:before {
    content: "👤 ";
}

.activity-stage {
    color: var(--text-muted);
}

.activity-view-all {
    margin-top: 1rem;
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.activity-view-all:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

/* ========================================
   COMPACT TIMELINE (for list views)
   ======================================== */

.timeline-compact {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
}

.compact-progress {
    flex: 1;
    max-width: 150px;
}

.compact-progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
}

.compact-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--info-color) 100%);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.compact-progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.compact-stage {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.compact-stage-icon {
    font-size: 1rem;
    color: var(--primary-color);
}

.compact-stage-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.compact-stage-dept {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ========================================
   LOCATION EDITOR
   ======================================== */

.location-editor {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 2rem;
}

.location-editor-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1.5rem 0;
}

.location-editor-form {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

/* Scoped form styles - only affect forms within unified tracker */
#document-tracker-tab .form-group,
.unified-tracker-main .form-group {
    margin-bottom: 1.5rem;
}

#document-tracker-tab .form-group:last-child,
.unified-tracker-main .form-group:last-child {
    margin-bottom: 0;
}

#document-tracker-tab .form-row,
.unified-tracker-main .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

#document-tracker-tab .form-group label,
.unified-tracker-main .form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

#document-tracker-tab .form-control,
.unified-tracker-main .form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--bg-primary);
}

#document-tracker-tab .form-control:focus,
.unified-tracker-main .form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-help {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.mt-1 {
    margin-top: 0.5rem;
}

.location-editor-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* Scoped button styles - only affect buttons within unified tracker */
#document-tracker-tab .btn,
.unified-tracker-main .btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

#document-tracker-tab .btn-primary,
.unified-tracker-main .btn-primary {
    background: var(--primary-color);
    color: white;
}

#document-tracker-tab .btn-primary:hover,
.unified-tracker-main .btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#document-tracker-tab .btn-secondary,
.unified-tracker-main .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

#document-tracker-tab .btn-secondary:hover,
.unified-tracker-main .btn-secondary:hover {
    background: var(--border-dark);
}

.location-current-display {
    margin-top: 2rem;
}

.location-current-display h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
}

.location-display-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.location-part {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.location-part strong {
    color: var(--text-primary);
    margin-right: 0.5rem;
}

/* Location History */
.location-history {
    padding: 2rem;
}

.history-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1.5rem 0;
}

.history-timeline {
    position: relative;
}

.history-item {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-item:not(:last-child):after {
    content: "";
    position: absolute;
    left: 0.375rem;
    top: 1.5rem;
    bottom: -1.5rem;
    width: 2px;
    background: var(--border-color);
}

.history-marker {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background: var(--primary-color);
    flex-shrink: 0;
    margin-top: 0.5rem;
    position: relative;
    z-index: 2;
}

.history-item-latest .history-marker {
    width: 1rem;
    height: 1rem;
    background: var(--success-color);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.history-content {
    flex: 1;
}

.history-date {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.history-action {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.history-details {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.history-officer {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Compact Location */
.compact-location {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.compact-location-physical {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.compact-location-holder {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* ========================================
   ALERT MESSAGES
   ======================================== */

.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    font-weight: 500;
    box-shadow: var(--shadow-md);
}

.alert-success {
    background: var(--success-light);
    color: #047857;
    border: 1px solid var(--success-color);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .tracking-timeline {
        padding: 1rem;
    }

    .timeline-header {
        padding: 1.5rem;
    }

    .timeline-title {
        font-size: 1.25rem;
    }

    .timeline-header-meta {
        grid-template-columns: 1fr;
    }

    .timeline-location-card {
        flex-direction: column;
        gap: 1rem;
    }

    .stage-content {
        padding: 1rem;
    }

    .stage-name {
        font-size: 1.125rem;
    }

    .stage-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .timeline-activity {
        padding: 1rem;
    }

    .activity-title {
        font-size: 1.25rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .location-editor-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .timeline-stage {
        gap: 1rem;
    }

    .stage-marker {
        width: 3rem;
        height: 3rem;
    }

    .stage-icon {
        width: 3rem;
        height: 3rem;
        font-size: 1.25rem;
    }

    .stage-connector {
        left: 1.5rem;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .tracking-timeline {
        padding: 0;
    }

    .timeline-header {
        background: white;
        color: black;
        border: 2px solid black;
    }

    .location-editor-buttons,
    .activity-view-all,
    .btn {
        display: none;
    }

    .stage-content:hover {
        box-shadow: none;
    }

    @page {
        margin: 2cm;
    }
}
