/* assets/css/style.css - Main stylesheet */

/* === Variables === */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #475569;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* === Layout === */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.main-layout {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    padding: 20px;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 5px;
}

.sidebar-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    margin-bottom: 5px;
}

.sidebar-nav a:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--accent);
    color: white;
}

.sidebar-nav .icon {
    font-size: 1.25rem;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* === Main Content === */
.main-content {
    flex: 1;
    padding: 30px;
    overflow-x: auto;
}

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

.page-header h2 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.page-header p {
    color: var(--text-muted);
}

/* === Cards === */
.card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px var(--shadow);
    backdrop-filter: blur(10px);
}

.card-glass {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(71, 85, 105, 0.5);
}

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

.stat-card {
    padding: 20px;
}

.stat-card .label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-card .icon {
    font-size: 2.5rem;
    opacity: 0.3;
    float: right;
}

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

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

.form-control {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    transition: all 0.2s;
}

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

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
}

/* === Buttons === */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

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

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

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

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

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

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

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

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

/* === Tables === */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg-tertiary);
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

tbody td {
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

tbody tr {
    transition: background 0.2s;
}

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

/* === Badges === */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-info {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
}

/* === Toast Notifications === */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-secondary);
    color: var(--text);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

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

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

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

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

/* === Modal === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.badge-info {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

.badge-warning {
    background: linear-gradient(135deg, #ffc107 0%, #ffa000 100%);
    color: #000;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

.badge-danger {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(244, 67, 54, 0.3);
}

.badge-secondary {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* === Animations === */
@keyframes pulse {

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

    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

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

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

/* === Responsive === */
@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .main-content {
        padding: 15px;
    }

    .page-header {
        margin-bottom: 20px;
    }

    .page-header h2 {
        font-size: 1.5rem;
    }

    /* Stats grid - 1 column on mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Dashboard expiring accounts grid - 1 column on mobile */
    #expiringAccountsGrid {
        grid-template-columns: 1fr !important;
    }

    /* Available accounts grid - responsive */
    #availableAccountsGrid {
        grid-template-columns: 1fr !important;
    }

    /* Chart container - reduce height on mobile */
    .card canvas {
        max-height: 250px !important;
    }

    /* Filter controls - stack vertically */
    .card>div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Dashboard chart header - stack vertically */
    .card>div[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start !important;
    }

    .card>div[style*="display: flex"][style*="justify-content: space-between"]>div[style*="display: flex"] {
        flex-direction: column;
        width: 100%;
    }

    .card>div[style*="display: flex"][style*="justify-content: space-between"] select {
        width: 100% !important;
    }

    /* Table responsive */
    table {
        font-size: 0.875rem;
    }

    thead th,
    tbody td {
        padding: 10px 8px;
    }

    /* Modal fullscreen on mobile */
    .modal-content {
        width: 95%;
        max-height: 95vh;
        padding: 20px;
    }

    /* Button improvements for touch */
    .btn {
        padding: 14px 20px;
    }

    .btn-sm {
        padding: 10px 14px;
    }

    /* Pagination centered and wrapped */
    .pagination {
        flex-wrap: wrap;
    }

    /* Page header flex - stack vertically */
    .page-header.flex {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start !important;
    }

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

/* Desktop: 2-4 columns based on screen size */
@media (min-width: 769px) and (max-width: 1200px) {
    #availableAccountsGrid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
    }
}

@media (min-width: 1201px) {
    #availableAccountsGrid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
    }
}

/* === Utilities === */
.text-center {
    text-align: center;
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-20 {
    margin-top: 20px;
}

.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.gap-10 {
    gap: 10px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 36px;
}

.pagination button:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.pagination button.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

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

/* === Tom Select Overrides === */
.ts-control {
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    color: var(--text) !important;
    padding: 8px 12px !important;
}
.ts-control input {
    color: var(--text) !important;
}
.ts-dropdown {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: 8px !important;
    margin-top: 4px;
}
.ts-dropdown .option {
    color: var(--text);
    padding: 8px 12px;
}
.ts-dropdown .option.active, .ts-dropdown .option:hover {
    background: var(--bg-hover) !important;
    color: var(--text) !important;
}