/* ==============================================================================
   style.css - Edge Protocol Demo Dashboard
   ==============================================================================
   
   Design: Premium dark theme with glassmorphism, matching Guardian-One style.
   
   ============================================================================== */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #141b2d;
    --bg-card: rgba(20, 27, 45, 0.8);
    --border-color: rgba(99, 102, 241, 0.3);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --glass: rgba(255, 255, 255, 0.05);
}

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

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

/* Header */
.header {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header .subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.badge {
    background: var(--accent-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Main container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--bg-secondary);
    padding: 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
}

.tab {
    flex: 1;
    padding: 0.875rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--glass);
}

.tab.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
}

.card h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Form elements */
.input-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
}

button {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 0.5rem;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

button.secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

button.danger {
    background: linear-gradient(135deg, var(--error), #dc2626);
}

/* Result display */
.result {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    margin-top: 1rem;
}

.result.success {
    border-color: var(--success);
}

.result.error {
    border-color: var(--error);
}

.result-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
}

.result-value {
    word-break: break-all;
}

/* Rate limit progress */
.progress-container {
    margin: 1rem 0;
}

.progress-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--accent-primary));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill.warning {
    background: linear-gradient(90deg, var(--warning), var(--error));
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Live countdown animation */
.countdown-urgent {
    color: var(--error);
    font-weight: 600;
    animation: pulse-urgent 1s ease-in-out infinite;
}

@keyframes pulse-urgent {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.countdown-ready {
    color: var(--success);
    font-weight: 600;
}

.countdown-refreshing {
    color: var(--accent-primary);
    font-weight: 600;
    animation: pulse-urgent 0.5s ease-in-out infinite;
}

/* Capability buttons */
.capability-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.capability-btn {
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.capability-btn:hover {
    border-color: var(--accent-primary);
    background: var(--glass);
}

.capability-btn.allowed {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.capability-btn.blocked {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

/* Status indicators */
.status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status.allowed {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.status.blocked {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.stat {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Loading spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* URL History Table */
.url-history-table {
    overflow-x: auto;
}

.url-history-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.url-history-table th,
.url-history-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.url-history-table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.url-history-table tr:hover {
    background: var(--glass);
}

.click-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

button.secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

button.secondary:hover {
    background: var(--glass);
    border-color: var(--accent-primary);
}

.storage-disclaimer {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .tabs {
        flex-direction: column;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .input-group {
        flex-direction: column;
    }

    /* Card-based layout for URL history on mobile */
    .url-history-table table,
    .url-history-table thead,
    .url-history-table tbody,
    .url-history-table th,
    .url-history-table td,
    .url-history-table tr {
        display: block;
    }

    .url-history-table thead {
        display: none;
    }

    .url-history-table tr {
        margin-bottom: 1rem;
        background: var(--bg-primary);
        border-radius: 0.5rem;
        padding: 0.75rem;
        border: 1px solid var(--border-color);
    }

    .url-history-table td {
        border: none;
        padding: 0.25rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .url-history-table td:first-child {
        font-weight: 600;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 0.5rem;
    }

    .url-history-table td:first-child a {
        word-break: break-all;
    }

    .url-history-table td:nth-child(2) {
        font-size: 0.75rem;
    }

    .url-history-table td:nth-child(2)::before {
        content: "Original: ";
        font-weight: 500;
        color: var(--text-secondary);
    }

    .url-history-table td:nth-child(3)::before {
        content: "Clicks: ";
        font-weight: 500;
        color: var(--text-secondary);
    }

    .url-history-table td:nth-child(4)::before {
        content: "Created: ";
        font-weight: 500;
        color: var(--text-secondary);
    }

    .url-history-table td:last-child {
        justify-content: flex-end;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-color);
        margin-top: 0.5rem;
    }

    .delete-btn {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 1rem;
    }

    .click-badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
}