/* =================================
   Modern Testify Dashboard - CSS
   Enhanced with Terminal-Style Log Viewer
   ================================= */

/* CSS Variables */
:root {
    /* Colors */
    --primary-blue: #3b82f6;
    --primary-blue-dark: #2563eb;
    --primary-blue-light: #60a5fa;
    --success-green: #10b981;
    --danger-red: #ef4444;
    --warning-orange: #f59e0b;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-light: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    /* Terminal Colors */
    --terminal-bg: #1e1e1e;
    --terminal-text: #00ff00;
    --terminal-dim: #00aa00;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-xl);
}

/* Header */
header {
    background: var(--bg-gradient);
    padding: var(--space-xl);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--space-xl);
    color: white;
}

.brand {
    text-align: left;
}

.company-name {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    opacity: 0.9;
    text-transform: uppercase;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: var(--space-xs) 0;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Card */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
    font-weight: 600;
}

/* Control Panel */
.control-panel {
    background: linear-gradient(to right, #ffffff, #f8fafc);
}

.control-form {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.form-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-group select {
    padding: 0.625rem var(--space-md);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 140px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-group select:hover {
    border-color: var(--primary-blue-light);
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn {
    padding: 0.625rem var(--space-lg);
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    transition: all 0.2s ease;
    text-decoration: none;
    color: white;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-start {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
}

.btn-start:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-blue-dark) 0%, #1e40af 100%);
}

.btn-stop {
    background: linear-gradient(135deg, var(--danger-red) 0%, #dc2626 100%);
}

.btn-stop:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.btn-sm {
    padding: 0.5rem var(--space-md);
    font-size: 0.8125rem;
}

.btn-outline {
    background: transparent;
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-blue);
    color: white;
}

.btn-icon {
    font-size: 1rem;
}

/* Status Indicator */
.status-indicator {
    margin-left: auto;
    font-size: 0.875rem;
    font-weight: 600;
}

.status-running {
    color: var(--warning-orange);
    animation: pulse 2s ease-in-out infinite;
}

.status-ready {
    color: var(--success-green);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* LOG VIEWER - Terminal Style */
.log-viewer {
    background: var(--terminal-bg);
    border: 2px solid #333;
    box-shadow: var(--shadow-xl);
    padding: 0;
    margin-bottom: var(--space-xl);
    overflow: hidden;
}

.log-header {
    background: #2d2d2d;
    padding: var(--space-md) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
}

.log-header h3 {
    color: #00ff00;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.log-actions {
    display: flex;
    gap: var(--space-sm);
}

.log-actions .btn-sm {
    background: #333;
    color: #00ff00;
    border: 1px solid #555;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.log-actions .btn-sm:hover {
    background: #444;
    border-color: #00ff00;
}

.log-content {
    background: var(--terminal-bg);
    color: var(--terminal-text);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    padding: var(--space-lg);
    margin: 0;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.log-content::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.log-content::-webkit-scrollbar-track {
    background: #0a0a0a;
}

.log-content::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 6px;
}

.log-content::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead {
    background: var(--bg-light);
}

th {
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

tr:hover {
    background: var(--bg-light);
}

.timestamp {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-new {
    background: #dcfce7;
    color: #166534;
}

.status-old {
    background: var(--bg-light);
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    color: var(--text-secondary);
    text-align: center;
    padding: var(--space-xl);
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }

    header h1 {
        font-size: 2rem;
    }

    .control-form {
        flex-direction: column;
        align-items: stretch;
    }

    .status-indicator {
        margin-left: 0;
    }

    table {
        font-size: 0.75rem;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Loading Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-loading .btn-icon {
    animation: spin 1s linear infinite;
}

/* MODAL STYLES */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.2s ease-in;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--terminal-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 2px solid #333;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    background: #2d2d2d;
    padding: var(--space-lg);
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    color: #00ff00;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
}

.modal-actions .btn-sm {
    background: #333;
    color: #00ff00;
    border: 1px solid #555;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.modal-actions .btn-sm:hover {
    background: #444;
    border-color: #00ff00;
}

.btn-close {
    background: #444 !important;
    color: #fff !important;
    font-size: 1.2rem !important;
    padding: 0.25rem 0.5rem !important;
    line-height: 1 !important;
}

.btn-close:hover {
    background: #ef4444 !important;
    color: #fff !important;
}

.modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-body .log-content {
    flex: 1;
    max-height: none;
}

/* REPORT BUTTONS */
.report-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn-report {
    background: var(--primary-blue);
    color: white;
    white-space: nowrap;
}

.btn-report:hover {
    background: var(--primary-blue-dark);
}

.btn-report.btn-outline {
    background: transparent;
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
}

.btn-report.btn-outline:hover {
    background: var(--primary-blue);
    color: white;
}

.btn-screenshots {
    background: transparent !important;
    color: #059669 !important;
    border: 2px solid #059669 !important;
}

.btn-screenshots:hover {
    background: #059669 !important;
    color: white !important;
}

.btn-log {
    background: transparent !important;
    color: #7c3aed !important;
    border: 2px solid #7c3aed !important;
}

.btn-log:hover {
    background: #7c3aed !important;
    color: white !important;
}

.btn-view-logs {
    background: var(--warning-orange);
    color: white;
}

.btn-view-logs:hover {
    background: #d97706;
}

/* RUNNING BADGE */
.running-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: #fef3c7;
    color: #92400e;
    border-radius: 12px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: #f59e0b;
    border-radius: 50%;
    animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* TABLE WRAPPER */
.table-wrapper {
    overflow-x: auto;
}

/* Responsive fixes for buttons */
@media (max-width: 768px) {
    .report-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-report,
    .btn-view-logs {
        width: 100%;
        justify-content: center;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* ====================================
   ENHANCED REPORT CARDS WITH SUMMARIES
   ==================================== */

/* Reports List Container */
.reports-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Individual Report Card */
.report-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: var(--space-lg);
    transition: all 0.3s ease;
}

.report-card:hover {
    border-color: var(--primary-blue-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Report Header */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--border-color);
}

.report-title {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.report-overall-status {
    font-size: 0.875rem;
    font-weight: 700;
    padding: 0.5rem var(--space-lg);
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-passed {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #065f46;
    border: 2px solid var(--success-green);
}

.status-failed {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #991b1b;
    border: 2px solid var(--danger-red);
}

/* Summary Metrics Grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.metric-card {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: var(--space-md);
    text-align: center;
    transition: all 0.2s ease;
}

.metric-card:hover {
    border-color: var(--primary-blue-light);
    transform: translateY(-2px);
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.metric-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-success {
    background: linear-gradient(135deg, #d1fae5, #ecfdf5);
    border-color: var(--success-green);
}

.metric-success .metric-value {
    color: var(--success-green);
}

.metric-error {
    background: linear-gradient(135deg, #fee2e2, #fef2f2);
    border-color: var(--danger-red);
}

.metric-error .metric-value {
    color: var(--danger-red);
}

/* Test Type Breakdown */
.test-breakdown {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-light);
    border-radius: 10px;
}

.test-type {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.test-type-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.test-type-icon {
    font-size: 1.25rem;
}

.test-type-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.test-type-badge {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: var(--success-green);
    color: white;
}

.badge-error {
    background: var(--danger-red);
    color: white;
}

.test-type-stats {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding-left: 2rem;
}

.stat-separator {
    margin: 0 var(--space-sm);
    opacity: 0.5;
}

/* Report Actions */
.report-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    align-items: center;
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

/* Responsive Design for Report Cards */
@media (max-width: 768px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .report-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .report-overall-status {
        align-self: stretch;
        text-align: center;
    }

    .report-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .report-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .test-breakdown {
        font-size: 0.875rem;
    }
}