/* ===========================================
   Arkitecht Billing Admin - Styles
   Based on OCPP Test Tool design system
   =========================================== */

:root {
    --primary: #f5d773;
    --primary-dark: #e5c763;
    --secondary: #EEEBE1;
    --secondary-dark: #dedad0;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --text-dark: #333;
    --text-muted: #666;
    --text-light: #999;
    --bg-light: #f9f9f9;
    --bg-white: #ffffff;
    --border-color: #eee;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
}

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

/* ===========================================
   Login Screen
   =========================================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--bg-light) 100%);
    padding: 20px;
}

.login-box {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-header {
    margin-bottom: 30px;
}

.login-logo {
    height: 40px;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--text-dark);
}

.environment-selector {
    margin-top: 24px;
}

.env-buttons {
    display: flex;
    gap: 12px;
}

.env-btn {
    flex: 1;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.env-btn i {
    font-size: 24px;
    color: var(--text-muted);
}

.env-btn span {
    font-size: 14px;
    color: var(--text-muted);
}

.env-btn:hover {
    border-color: var(--primary);
    background: rgba(245, 215, 115, 0.1);
}

.env-btn.selected {
    border-color: var(--primary);
    background: rgba(245, 215, 115, 0.2);
}

.env-btn.selected i,
.env-btn.selected span {
    color: var(--text-dark);
}

.env-btn[data-env="dev"].selected {
    border-color: var(--info);
    background: rgba(23, 162, 184, 0.1);
}

.env-btn[data-env="prod"].selected {
    border-color: var(--danger);
    background: rgba(220, 53, 69, 0.1);
}

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

.login-status.error {
    color: var(--danger);
}

/* ===========================================
   Top Bar
   =========================================== */

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-bar-logo {
    height: 32px;
}

.top-bar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.top-bar-center {
    display: flex;
    align-items: center;
    gap: 16px;
}

.env-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.env-badge.env-dev {
    background: rgba(23, 162, 184, 0.15);
    color: var(--info);
}

.env-badge.env-prod {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-light);
}

.status-dot.online {
    background: var(--success);
}

.status-dot.offline {
    background: var(--text-light);
}

.status-dot.error {
    background: var(--danger);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

/* ===========================================
   Desktop (App Icons)
   =========================================== */

.main-app {
    padding-top: 60px;
    min-height: 100vh;
}

.desktop {
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: calc(100vh - 60px);
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 24px;
    max-width: 600px;
    width: 100%;
}

.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    background: var(--bg-white);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
}

.app-icon:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.app-icon-img {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary);
    border-radius: var(--radius);
    transition: transform 0.2s ease;
}

.app-icon:hover .app-icon-img {
    transform: scale(1.1);
}

.app-icon-img i {
    font-size: 28px;
    color: var(--text-dark);
}

.app-icon span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
}

/* ===========================================
   App Windows
   =========================================== */

.app-window {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-light);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.app-window.active {
    display: flex;
}

.app-header {
    position: sticky;
    top: 0;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100;
}

.back-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.back-btn:hover {
    background: var(--secondary);
}

.back-btn i {
    font-size: 20px;
    color: var(--text-dark);
}

.app-header h2 {
    flex: 1;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header h2 i {
    color: var(--primary-dark);
}

.app-header-actions {
    display: flex;
    gap: 8px;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 80px;
}

/* ===========================================
   Cards
   =========================================== */

.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: none;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 20px;
}

/* ===========================================
   Tables
   =========================================== */

.table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

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

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

/* ===========================================
   Buttons
   =========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 16px;
}

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

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

.btn-primary:disabled {
    background: var(--secondary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: var(--secondary-dark);
}

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

.btn-success:hover {
    background: #218838;
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn-link {
    background: none;
    color: var(--info);
    padding: 0;
    text-decoration: underline;
}

.btn-link:hover {
    color: #138496;
}

/* ===========================================
   Forms
   =========================================== */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(245, 215, 115, 0.2);
}

.form-control::placeholder {
    color: var(--text-light);
}

select.form-control {
    cursor: pointer;
}

input[type="date"].form-control {
    padding: 12px 16px;
    font-size: 15px;
    min-height: 48px;
    cursor: pointer;
}

input[type="date"].form-control::-webkit-calendar-picker-indicator {
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

input[type="date"].form-control::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* ===========================================
   Badges & Status
   =========================================== */

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgba(40, 167, 69, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(255, 193, 7, 0.15);
    color: #d39e00;
}

.badge-danger {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger);
}

.badge-info {
    background: rgba(23, 162, 184, 0.15);
    color: var(--info);
}

.badge-secondary {
    background: rgba(108, 117, 125, 0.15);
    color: #6c757d;
}

/* ===========================================
   Results Panel (API Log)
   =========================================== */

.results-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    z-index: 900;
    max-height: 300px;
    transition: transform 0.3s ease;
}

.results-panel.minimized {
    transform: translateY(calc(100% - 40px));
}

.results-header {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}

.results-header span {
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.results-panel.minimized .toggle-icon {
    transform: rotate(180deg);
}

.results-body {
    max-height: 250px;
    overflow-y: auto;
    padding: 0;
}

.no-logs {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.log-entry {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry-header {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.log-method {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.log-method.get { background: #e3f2fd; color: #1976d2; }
.log-method.post { background: #e8f5e9; color: #388e3c; }
.log-method.put { background: #fff3e0; color: #f57c00; }
.log-method.delete { background: #ffebee; color: #d32f2f; }

.log-url {
    flex: 1;
    color: var(--text-dark);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-status {
    font-weight: 500;
}

.log-status.success { color: var(--success); }
.log-status.error { color: var(--danger); }

.log-time {
    color: var(--text-light);
    font-size: 11px;
}

.log-body {
    display: none;
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 11px;
    white-space: pre-wrap;
    overflow-x: auto;
}

.log-entry.expanded .log-body {
    display: block;
}

/* ===========================================
   Toast Notifications
   =========================================== */

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast.removing {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--info); }
.toast-warning { border-left: 4px solid var(--warning); }

.toast i {
    font-size: 18px;
}

.toast-success i { color: var(--success); }
.toast-error i { color: var(--danger); }
.toast-info i { color: var(--info); }
.toast-warning i { color: var(--warning); }

/* ===========================================
   Modal
   =========================================== */

.billing-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.billing-modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.billing-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.billing-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.billing-modal-close:hover {
    background: var(--secondary);
}

.billing-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.billing-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===========================================
   Loading & Empty States
   =========================================== */

.loading-state,
.empty-state,
.error-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.loading-state i,
.empty-state i,
.error-state i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.loading-state i {
    animation: spin 1s linear infinite;
}

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

.spinning {
    animation: spin 1s linear infinite;
}

.error-state i {
    color: var(--danger);
}

.empty-state p,
.error-state p {
    margin: 0;
    font-size: 14px;
}

/* ===========================================
   Pagination
   =========================================== */

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.pagination-pages {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pagination-pages .btn {
    min-width: 36px;
    padding: 4px 8px;
}

.pagination-ellipsis {
    padding: 0 4px;
    color: var(--text-muted);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-left: 12px;
}

/* ===========================================
   Filter Section
   =========================================== */

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* ===========================================
   Stats Cards
   =========================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.primary { background: rgba(245, 215, 115, 0.2); color: var(--primary-dark); }
.stat-icon.success { background: rgba(40, 167, 69, 0.15); color: var(--success); }
.stat-icon.info { background: rgba(23, 162, 184, 0.15); color: var(--info); }
.stat-icon.warning { background: rgba(255, 193, 7, 0.15); color: #d39e00; }

.stat-content h4 {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.stat-content p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

/* ===========================================
   Invoice Preview
   =========================================== */

.invoice-preview {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 24px;
}

.invoice-preview-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.invoice-preview-lines {
    margin-bottom: 24px;
}

.invoice-line {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.invoice-line.header {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 8px;
}

.invoice-totals {
    border-top: 2px solid var(--border-color);
    padding-top: 16px;
}

.invoice-total-line {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.invoice-total-line.grand-total {
    font-size: 18px;
    font-weight: 600;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

/* ===========================================
   Utility Classes
   =========================================== */

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: #d39e00; }
.text-info { color: var(--info); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

.w-100 { width: 100%; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

.font-mono {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===========================================
   Responsive
   =========================================== */

@media (max-width: 768px) {
    .top-bar {
        padding: 0 12px;
    }

    .top-bar-title {
        display: none;
    }

    .top-bar-center {
        gap: 8px;
    }

    .desktop {
        padding: 20px;
    }

    .app-content {
        padding: 12px;
    }

    .card-body {
        padding: 16px;
    }

    .billing-modal {
        margin: 12px;
        max-height: calc(100vh - 24px);
    }

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

    .filter-grid {
        grid-template-columns: 1fr;
    }

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