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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #16a34a;
    --success-hover: #15803d;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

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

.login-box {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--text-color);
    font-size: 28px;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 30px;
}

/* Header */
.header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-title {
    font-size: 24px;
    color: var(--text-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.saldo-display {
    background: var(--bg-color);
    padding: 10px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.saldo-label {
    color: var(--text-muted);
    font-size: 14px;
}

.saldo-valor {
    font-size: 20px;
    font-weight: 700;
    color: var(--success-color);
}

/* Main Content */
.main-content {
    padding: 30px 20px;
}

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

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 20px;
    color: var(--text-color);
    margin-bottom: 20px;
}

/* Forms */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-hint {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

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

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-logout {
    background: var(--danger-color);
    color: white;
}

.btn-logout:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-large {
    width: 100%;
    padding: 14px 20px;
    font-size: 18px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
}

/* Messages */
.error-message {
    display: none;
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 15px;
    border-left: 4px solid var(--danger-color);
}

.error-message.show {
    display: block;
}

.success-message {
    display: none;
    background: #d1fae5;
    color: #065f46;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 15px;
    border-left: 4px solid var(--success-color);
}

.success-message.show {
    display: block;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--primary-color);
}

/* Preço Info */
.preco-info {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
}

.preco-info.show {
    display: block;
}

/* Histórico */
.historico-table {
    width: 100%;
    border-collapse: collapse;
}

.historico-table th {
    text-align: left;
    padding: 12px;
    background: var(--bg-color);
    color: var(--text-color);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.historico-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.historico-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

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

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

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 30px;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: white;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Utilities */
.text-muted {
    color: var(--text-muted);
}

/* Resultado */
.resultado-texto {
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    background: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    line-height: 1.8;
    font-size: 14px;
    color: var(--text-color);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

/* ==================== API KEYS PAGE ==================== */

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* API Key Cards */
.api-key-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.api-key-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.api-key-card.revogada {
    opacity: 0.6;
    background: #f9fafb;
}

.api-key-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.api-key-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
}

.api-key-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.api-key-status.ativo {
    background: #d1fae5;
    color: #065f46;
}

.api-key-status.revogado {
    background: #fee2e2;
    color: #991b1b;
}

.api-key-actions {
    display: flex;
    gap: 10px;
}

.api-key-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.key-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.key-info label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.key-display-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.key-display-inline code {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--text-color);
    word-break: break-all;
}

.secret-hidden {
    color: var(--text-muted) !important;
}

.btn-copy-inline {
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-copy-inline:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.key-meta {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: var(--text-muted);
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

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

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--text-color);
}

.empty-state p {
    color: var(--text-muted);
}

/* Documentation Sections */
.doc-section {
    margin-bottom: 40px;
}

.doc-section h3 {
    font-size: 20px;
    margin-bottom: 15px;
    color: var(--text-color);
}

.doc-section p,
.doc-section li {
    margin-bottom: 10px;
    line-height: 1.8;
}

.doc-section ol {
    margin-left: 20px;
}

.doc-section ul {
    margin-left: 20px;
    list-style-type: disc;
}

.doc-section code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.doc-section pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
}

.doc-section pre code {
    background: none;
    color: #e2e8f0;
    padding: 0;
}

/* Endpoint Box */
.endpoint-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.http-method {
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    color: white;
}

.http-method.post {
    background: #16a34a;
}

.http-method.get {
    background: #2563eb;
}

.endpoint-url {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-color);
}

.btn-copy {
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-copy:hover {
    background: var(--primary-hover);
}

/* Price Table */
.price-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.price-table thead {
    background: #f8fafc;
}

.price-table th,
.price-table td {
    padding: 12px;
    text-align: left;
    border: 1px solid var(--border-color);
}

.price-table th {
    font-weight: 600;
    color: var(--text-color);
}

.price-table td strong {
    color: var(--success-color);
}

/* Code Examples */
.code-section {
    margin-bottom: 40px;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.code-header h3 {
    font-size: 18px;
}

/* Key Display Modal */
.key-display {
    margin-bottom: 20px;
}

.key-display label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.key-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #f8fafc;
    border: 2px solid var(--border-color);
    border-radius: 8px;
}

.key-box.secret {
    background: #fef3c7;
    border-color: #fbbf24;
}

.key-box code {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    word-break: break-all;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-info {
    background: #dbeafe;
    border: 1px solid #3b82f6;
    color: #1e40af;
}

.alert-warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
}

.alert strong {
    font-weight: 700;
}

/* Text Utilities */
.text-muted {
    color: var(--text-muted);
    font-size: 14px;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: -400px;
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    min-width: 300px;
    max-width: 400px;
    transition: right 0.3s ease;
    z-index: 10000;
}

.notification.show {
    right: 20px;
}

.notification.success {
    border-left: 4px solid var(--success-color);
}

.notification.error {
    border-left: 4px solid var(--danger-color);
}

.notification button {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
}

.notification button:hover {
    color: var(--text-color);
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-actions {
        justify-content: space-between;
    }
    
    .saldo-display {
        order: -1;
        width: 100%;
        justify-content: center;
    }
    
    .card {
        padding: 20px;
    }
    
    .historico-table {
        font-size: 14px;
    }
    
    .historico-table th,
    .historico-table td {
        padding: 8px;
    }
    
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-button {
        white-space: nowrap;
    }
    
    .api-key-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .api-key-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .key-meta {
        flex-direction: column;
        gap: 10px;
    }
    
    .endpoint-header {
        flex-wrap: wrap;
    }
    
    .code-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
