/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background-color: #fff;
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 24px;
    color: #0078d4;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Cards */
.card {
    background-color: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #0078d4;
}

.card h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background-color: #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background-color: #0078d4;
    transition: width 0.3s ease;
}

.progress-fill.warning {
    background-color: #ff9800;
}

.progress-fill.danger {
    background-color: #f44336;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #0078d4;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #005a9e;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #545b62;
}

.btn-warning {
    background-color: #ff9800;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background-color: #e68900;
}

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

.btn-large {
    padding: 15px 30px;
    font-size: 16px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.form-control:focus {
    outline: none;
    border-color: #0078d4;
}

select.form-control[multiple] {
    min-height: 100px;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background-color: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
}

.login-card h1 {
    color: #0078d4;
    margin-bottom: 10px;
}

.login-card p {
    color: #666;
    margin-bottom: 30px;
}

.login-info {
    margin-top: 30px;
    text-align: left;
}

.login-info h3 {
    font-size: 16px;
    margin-bottom: 10px;
}

.login-info ul {
    list-style-position: inside;
    color: #666;
}

.login-info li {
    margin-bottom: 5px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    max-width: 700px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.key-display {
    background-color: #f5f5f5;
    padding: 20px;
    border-radius: 4px;
    margin: 20px 0;
    text-align: center;
}

.key-display code {
    display: block;
    font-size: 14px;
    word-break: break-all;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.key-info {
    margin-top: 20px;
}

.key-info p {
    margin-bottom: 10px;
}

.model-pills {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    vertical-align: middle;
}

.model-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background-color: #e8f0fe;
    color: #1a56db;
    border: 1px solid #c3d7fd;
    white-space: nowrap;
}

/* Confirmation Dialog */
.confirm-dialog {
    max-width: 500px;
    text-align: center;
}

.confirm-dialog h2 {
    margin-bottom: 20px;
    color: #333;
}

.confirm-dialog p {
    margin-bottom: 30px;
    line-height: 1.6;
    color: #666;
    white-space: pre-line;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.confirm-buttons .btn {
    min-width: 120px;
}

/* Messages */
.info-text {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

.warning-text {
    color: #ff9800;
    font-weight: 500;
}

.warning-text code {
    background-color: #fff3e0;
    color: #e65100;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.error-text {
    color: #f44336;
    font-weight: 500;
}

.success-text {
    color: #4caf50;
    font-weight: 500;
}

.status-message {
    margin-top: 10px;
    font-size: 14px;
}

/* Key Actions */
.key-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* Key Details */
#active-key-details {
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

#active-key-details p {
    margin-bottom: 8px;
}

/* Budget Section within Active Key */
.budget-section {
    margin: 20px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border-left: 4px solid #0078d4;
}

.budget-section h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #0078d4;
    font-size: 16px;
}

/* Recent Keys List */
#recent-keys-list {
    display: grid;
    gap: 10px;
}

/* Removed old key-item styles - now using table format */

/* Loading State */
.loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Responsive */
@media (max-width: 768px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .key-actions {
        flex-direction: column;
    }

    .modal-content {
        margin: 20% 10px;
        padding: 20px;
    }

    /* Make table scrollable on mobile */
    .keys-table {
        font-size: 12px;
    }

    .keys-table th,
    .keys-table td {
        padding: 8px;
    }
}

/* Keys Table */
.table-responsive {
    overflow-x: auto;
    margin-top: 15px;
}

.keys-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.keys-table thead {
    background-color: #f5f5f5;
}

.keys-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #ddd;
}

.keys-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.keys-table tbody tr:hover {
    background-color: #f9f9f9;
}

.keys-table tbody tr.key-exhausted {
    opacity: 0.6;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-active {
    background-color: #d4edda;
    color: #155724;
}

.status-exhausted {
    background-color: #f8d7da;
    color: #721c24;
}

.status-blocked {
    background-color: #d6d8db;
    color: #383d41;
}

/* Usage Statistics */
.usage-periods-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .usage-periods-container {
        grid-template-columns: 1fr;
    }
}

.usage-period {
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.usage-period:last-child {
    border-bottom: 1px solid #e0e0e0;
}

.usage-period h3 {
    color: #0078d4;
    margin-bottom: 15px;
    font-size: 18px;
}

.usage-period h4 {
    color: #666;
    font-size: 14px;
    margin-top: 15px;
    margin-bottom: 10px;
}

.usage-summary {
    display: flex;
    gap: 30px;
    margin-bottom: 15px;
}

.usage-summary p {
    margin: 0;
}

.model-breakdown {
    background-color: #ffffff;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.model-spend-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.model-spend-item:last-child {
    border-bottom: none;
}

.model-name {
    color: #333;
    font-weight: 500;
}

.model-spend {
    color: #0078d4;
    font-weight: 600;
}

/* Access Denied / User Not Found */
.access-denied-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 20px;
}

.access-denied-card {
    background-color: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    text-align: center;
}

.access-denied-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.access-denied-card h2 {
    color: #d9534f;
    margin-bottom: 20px;
    font-size: 28px;
}

.access-denied-message {
    font-size: 16px;
    color: #333;
    margin-bottom: 30px;
    line-height: 1.6;
}

.access-denied-details {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 4px;
    margin-bottom: 30px;
    text-align: left;
}

.access-denied-details p {
    margin-bottom: 10px;
}

.access-denied-details code {
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #0078d4;
    font-weight: 600;
}

.access-denied-actions {
    background-color: #e7f3ff;
    padding: 20px;
    border-radius: 4px;
    border-left: 4px solid #0078d4;
    margin-bottom: 30px;
    text-align: left;
}

.access-denied-actions p {
    margin-bottom: 15px;
    font-weight: 600;
    color: #0078d4;
}

.access-denied-actions ol {
    margin-left: 20px;
    line-height: 1.8;
}

.access-denied-actions li {
    margin-bottom: 8px;
    color: #333;
}

.access-denied-actions code {
    background-color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #0078d4;
    font-weight: 600;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid #2196F3;
    pointer-events: all;
    max-width: 400px;
}

.toast.error {
    border-left-color: #f44336;
}

.toast.success {
    border-left-color: #4CAF50;
}

.toast.warning {
    border-left-color: #ff9800;
}

.toast.info {
    border-left-color: #2196F3;
}

.toast.hiding {
    animation: slideOutRight 0.3s ease-in forwards;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
    line-height: 1;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-message {
    font-size: 14px;
    color: #333;
    margin: 0;
    word-wrap: break-word;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    background: #f0f0f0;
    color: #666;
}

@keyframes slideInRight {
    from {
        transform: translateX(420px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(420px);
        opacity: 0;
    }
}

@media (max-width: 480px) {
    .toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast {
        max-width: none;
    }
}

/* Key Usage Instructions */
.key-usage-instructions {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.key-usage-instructions h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #333;
}

.usage-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.usage-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: color 0.2s, border-color 0.2s;
}

.usage-tab:hover {
    color: #0078d4;
}

.usage-tab.active {
    color: #0078d4;
    border-bottom-color: #0078d4;
}

.usage-content {
    display: none;
}

.usage-content.active {
    display: block;
}

.usage-content p {
    margin-bottom: 10px;
    font-size: 14px;
    color: #666;
}

.usage-content kbd {
    background-color: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
    color: #333;
    display: inline-block;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 2px 6px;
}

.usage-content code {
    background-color: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #d63384;
}

.config-block {
    background-color: #1e1e1e;
    color: #d4d4d4;
    padding: 15px;
    border-radius: 4px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
    margin-bottom: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.config-block .placeholder-highlight {
    background-color: #ff9800;
    color: #000;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
}

.usage-content .btn {
    margin-top: 5px;
}

.vscode-link {
    display: inline-block;
    background-color: #0078d4;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 10px;
    transition: background-color 0.2s;
}

.vscode-link:hover {
    background-color: #005a9e;
    color: white;
}

.link-note {
    font-size: 13px;
    color: #888;
    margin-left: 8px;
}

/* Usage Guidelines */
.guidelines-card {
    background-color: #e7f3ff;
    border-left: 4px solid #0078d4;
}

.guidelines-card h2 {
    font-size: 18px;
    margin-bottom: 12px;
}

.guidelines-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.guidelines-list li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 120, 212, 0.15);
    font-size: 14px;
}

.guidelines-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.guidelines-list code {
    background-color: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #0078d4;
    font-weight: 600;
}

.guidelines-list a {
    color: #0078d4;
    text-decoration: none;
}

.guidelines-list a:hover {
    text-decoration: underline;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    font-size: 12px;
    color: #999;
    border-top: 1px solid #eee;
}

.login-container ~ .site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin-top: 0;
    border-top: none;
    color: rgba(255, 255, 255, 0.6);
    background: transparent;
}
