/* Professional Left Sidebar Design System for Tally Integration Portal */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Outfit', 'Inter', sans-serif;

    /* Theme Colors */
    --bg-page: #0b0f19;
    --bg-sidebar: rgba(11, 15, 25, 0.95);
    --bg-card: rgba(18, 24, 38, 0.85);
    --bg-card-hover: rgba(26, 34, 53, 0.95);
    --border-card: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);

    --text-heading: #f8fafc;
    --text-body: #94a3b8;
    --text-muted: #64748b;

    /* Accent Gradients */
    --grad-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --grad-success: linear-gradient(135deg, #059669 0%, #10b981 100%);
    --grad-warning: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    --grad-danger: linear-gradient(135deg, #dc2626 0%, #f43f5e 100%);

    --color-primary: #6366f1;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #f43f5e;

    /* Sidebar Geometry */
    --sidebar-width: 260px;

    /* Shadows & Effects */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-primary);
}

body {
    background: var(--bg-page);
    background-image:
        radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-body);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--text-heading);
    letter-spacing: -0.02em;
    font-weight: 700;
}

/* Left Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-card);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid var(--border-card);
}

.sidebar-brand {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav {
    padding: 1.25rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.2rem 1rem;
    color: var(--text-body);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-nav-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}

.sidebar-nav-item.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(124, 58, 237, 0.25) 100%);
    border: 1px solid rgba(99, 102, 241, 0.35);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.sidebar-nav-item .icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 1.25rem 1.25rem;
    border-top: 1px solid var(--border-card);
    background: rgba(15, 23, 42, 0.4);
}

.user-profile-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--grad-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.user-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-logout {
    color: #f87171;
    text-decoration: none;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
}

.btn-logout:hover {
    background: rgba(248, 113, 113, 0.15);
}

/* Main Content Area */
.main-wrapper {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    padding-bottom: 60px;
}

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

/* Cards & Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--grad-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--border-glow);
}

.card:hover::before {
    opacity: 1;
}

.card-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.card-value {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-heading);
}

/* Dynamic Pulsing Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-online {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-offline {
    background: rgba(244, 63, 94, 0.15);
    color: #fb7185;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    position: relative;
}

.status-dot.online {
    background-color: var(--color-success);
    box-shadow: 0 0 10px var(--color-success);
    animation: pulse-green 2s infinite;
}

.status-dot.offline {
    background-color: var(--color-danger);
    box-shadow: 0 0 10px var(--color-danger);
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Button System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0.75rem 1.5rem;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: var(--grad-primary);
    color: #ffffff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
    opacity: 0.95;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--grad-danger);
    color: #ffffff;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(244, 63, 94, 0.4);
}

.btn-disabled {
    opacity: 0.4;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* Glassmorphic Data Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-muted);
    padding: 1.1rem 1.25rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border-card);
}

td {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.95rem;
    color: var(--text-heading);
}

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

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* Form Components */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: #cbd5e1;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.7);
    color: #ffffff;
    transition: all 0.25s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
    background: rgba(15, 23, 42, 0.9);
}

.form-control option {
    background: #0f172a;
    color: #ffffff;
}

/* Offline Banner Alert */
.alert-offline-block {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-left: 4px solid var(--color-danger);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.75rem;
    color: #fecdd3;
}

.alert-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.15rem;
    color: #ffffff;
    margin-bottom: 0.35rem;
}

/* Responsive Sidebar for Mobile */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }
}

.tally-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.tally-modal-overlay.active {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tally-modal-card {
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(99, 102, 241, 0.35);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 35px rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-lg);
    width: 92%;
    max-width: 520px;
    padding: 2rem;
    margin: auto;
    transform: translateY(20px) scale(0.96);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.tally-modal-overlay.active .tally-modal-card {
    transform: translateY(0) scale(1);
}

.tally-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tally-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tally-modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color 0.2s ease;
}

.tally-modal-close:hover {
    color: #ffffff;
}

.tally-modal-body {
    margin-bottom: 1.5rem;
}

.tally-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}