/* ==========================================================================
   TrackMail — Dashboard & App Pages
   ========================================================================== */

/* Stat Cards */
.stat-card {
    background: var(--paper-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--paper-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    opacity: 0.85;
}

.stat-card.primary::before { background: linear-gradient(90deg, var(--bronze-light), var(--bronze)); }
.stat-card.success::before { background: linear-gradient(90deg, #5a9a7a, var(--success)); }
.stat-card.danger::before { background: linear-gradient(90deg, #c06060, var(--danger)); }
.stat-card.warning::before { background: linear-gradient(90deg, #d4a843, var(--warning)); }

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.stat-card .card-body {
    padding: 1.375rem 1.5rem;
}

.stat-card-label {
    color: var(--ink-subtle);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.35rem;
}

.stat-card-value {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--ink-dark);
    line-height: 1.1;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-card.primary .stat-card-icon { background: var(--gold-glow); color: var(--bronze); }
.stat-card.success .stat-card-icon { background: var(--success-bg); color: var(--success); }
.stat-card.danger .stat-card-icon { background: var(--danger-bg); color: var(--danger); }
.stat-card.warning .stat-card-icon { background: var(--warning-bg); color: var(--warning); }

/* Activity list items */
.activity-list .list-group-item {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--paper-border) !important;
    padding: 1rem 1.25rem;
    transition: background var(--transition);
}

.activity-list .list-group-item:last-child {
    border-bottom: none !important;
}

.activity-list .list-group-item:hover {
    background: rgba(201, 169, 98, 0.04);
}

.activity-time-badge {
    background: var(--paper-light);
    border: 1px solid var(--paper-border);
    color: var(--ink-subtle);
    font-size: 0.7rem;
    font-family: 'DM Sans', monospace;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

/* Tables */
.table-custom {
    margin-bottom: 0;
}

.table-custom thead th {
    background: var(--paper-light) !important;
    color: var(--ink-subtle);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--paper-border);
    white-space: nowrap;
}

.table-custom tbody td {
    padding: 0.875rem 1.25rem;
    vertical-align: middle;
    color: var(--ink-muted);
    border-bottom: 1px solid var(--paper-border);
    font-size: 0.875rem;
}

.table-custom tbody tr {
    transition: background var(--transition);
}

.table-custom tbody tr:hover {
    background: rgba(201, 169, 98, 0.04);
}

.table-custom tbody tr:last-child td {
    border-bottom: none;
}

/* Search panel */
.search-panel {
    background: var(--paper-card);
    border: 1px solid var(--paper-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.search-panel .form-control-custom {
    border-left: none;
}

.search-panel .input-group-text-custom {
    border-right: none;
}

/* Pagination */
.pagination-custom {
    padding: 1.25rem;
    border-top: 1px solid var(--paper-border);
}

.pagination-custom .page-link {
    border: 1px solid var(--paper-border);
    color: var(--ink-muted);
    border-radius: var(--radius-sm) !important;
    margin: 0 0.15rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.pagination-custom .page-link:hover {
    background: var(--gold-glow);
    border-color: var(--bronze-light);
    color: var(--ink-dark);
}

.pagination-custom .page-item.active .page-link {
    background: linear-gradient(135deg, var(--bronze-light), var(--bronze));
    border-color: var(--bronze);
    color: var(--ink-dark);
    font-weight: 600;
}

/* Compose form */
.compose-card {
    background: var(--paper-card);
    border: 1px solid var(--paper-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.compose-card-header {
    background: linear-gradient(135deg, rgba(201, 169, 98, 0.08) 0%, transparent 100%);
    border-bottom: 1px solid var(--paper-border);
    padding: 1.25rem 1.5rem;
}

.compose-card-header h5 {
    margin: 0;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.compose-card-header h5 i {
    color: var(--bronze);
}

.compose-textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.7;
    font-size: 0.925rem;
}

.compose-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
    border-top: 1px solid var(--paper-border);
    margin-top: 0.5rem;
}

/* Email detail — analytics mini cards */
.detail-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.detail-stat-item {
    background: var(--paper-light);
    border: 1px solid var(--paper-border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
}

.detail-stat-item .label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-subtle);
    display: block;
    margin-bottom: 0.25rem;
}

.detail-stat-item .value {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink-dark);
}

.detail-stat-item .value-sm {
    font-family: 'DM Sans', monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink-muted);
    word-break: break-all;
}

/* Body preview — letter style */
.letter-preview {
    background: var(--paper-light);
    border: 1px solid var(--paper-border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--ink-muted);
    white-space: pre-wrap;
    max-height: 240px;
    overflow-y: auto;
    position: relative;
}

.letter-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 1.5rem;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, transparent, rgba(201, 169, 98, 0.15), transparent);
}

/* Timeline */
.timeline {
    position: relative;
    padding: 1.25rem 1.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 2.125rem;
    top: 1.5rem;
    bottom: 1.5rem;
    width: 2px;
    background: linear-gradient(180deg, var(--bronze-light), var(--paper-border));
}

.timeline-item {
    position: relative;
    padding-left: 2.75rem;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: 0;
    top: 0.15rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--paper-card-solid);
    border: 2px solid var(--bronze-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--bronze);
    z-index: 1;
    box-shadow: var(--shadow-sm);
}

.timeline-content {
    background: var(--paper-light);
    border: 1px solid var(--paper-border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    transition: box-shadow var(--transition);
}

.timeline-content:hover {
    box-shadow: var(--shadow-sm);
}

.timeline-time {
    font-family: 'DM Sans', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-dark);
    margin-bottom: 0.35rem;
}

.timeline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--ink-subtle);
}

.timeline-meta code {
    background: rgba(166, 124, 82, 0.08);
    color: var(--bronze-dark);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Detail action buttons */
.btn-detail {
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    transition: all var(--transition);
}

.btn-detail-info {
    background: var(--info-bg);
    border: 1px solid rgba(90, 122, 140, 0.2);
    color: var(--info);
}

.btn-detail-info:hover {
    background: var(--info);
    color: #fff;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* Back link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--ink-subtle);
    text-decoration: none;
    margin-bottom: 0.75rem;
    transition: color var(--transition);
}

.back-link:hover {
    color: var(--bronze);
}

@media (max-width: 767.98px) {
    .detail-stat-grid {
        grid-template-columns: 1fr;
    }

    .table-custom thead th,
    .table-custom tbody td {
        padding: 0.75rem 0.875rem;
    }

    .stat-card-value {
        font-size: 1.65rem;
    }
}
