/* Viva Layout System — Side navigation, responsive grid, modern spacing */

/* Root layout with sidebar */
.app-layout {
    display: flex;
    min-height: 100vh;
    background: var(--viva-white);
}

/* Sidebar Navigation */
.sidebar {
    width: 240px;
    background: var(--viva-violet);
    color: var(--viva-white);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--viva-white);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.sidebar-brand:hover {
    opacity: 0.9;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--viva-white);
}

.nav-item.active {
    background: rgba(0, 0, 0, 0.2);
    color: var(--viva-white);
    border-left-color: var(--viva-yellow);
}

.nav-icon {
    font-size: 1.2rem;
    min-width: 28px;
    text-align: center;
}

.nav-label {
    flex: 1;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.user-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.user-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-details {
    flex: 1;
    min-width: 0;
}

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

.user-logout {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s ease;
}

.user-logout:hover {
    color: var(--viva-white);
    text-decoration: underline;
}

/* Main content area */
.main-content {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--viva-white);
}

.main-content > * {
    padding: 1.5rem;
}

.main-content > .alert {
    padding: 1rem 1.5rem;
    margin: 0;
    border-radius: 0;
}

/* Breadcrumb navigation */
.breadcrumb {
    padding: 0.75rem 1.5rem;
    background: var(--viva-gray-bg);
    border-bottom: 1px solid var(--viva-gray-light);
    font-size: 0.85rem;
    color: var(--viva-gray-mid);
}

.breadcrumb ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}

.breadcrumb li {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.breadcrumb li + li::before {
    content: "/";
    color: var(--viva-gray-mid2);
    margin: 0 0.25rem;
}

.breadcrumb a {
    color: var(--viva-violet);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb li[aria-current="page"] {
    color: var(--viva-gray-dark);
    font-weight: 500;
}

.main-content > :last-child {
    flex: 1;
}

/* Footer */
.footer {
    grid-column: 1 / -1;
    padding: 1.5rem;
    text-align: center;
    color: var(--viva-gray-mid);
    font-size: 0.85rem;
    border-top: 1px solid var(--viva-gray-light);
    background: var(--viva-gray-bg);
    margin-top: auto;
}

/* Container and grid utilities */
.container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.container.full-width {
    grid-template-columns: 1fr;
}

.container.two-col {
    grid-template-columns: repeat(2, 1fr);
}

.container.three-col {
    grid-template-columns: repeat(3, 1fr);
}

/* Cards */
.card {
    background: var(--viva-white);
    border: 1px solid var(--viva-gray-light);
    border-radius: var(--viva-radius);
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: var(--viva-violet);
    box-shadow: 0 4px 12px rgba(87, 6, 140, 0.1);
}

.card-header {
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--viva-gray-dark);
    margin: 0;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--viva-gray-mid);
    margin: 0.25rem 0 0 0;
}

.card-body {
    margin: 0;
}

.card-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--viva-gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

/* Stats badges */
.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--viva-violet-10);
    color: var(--viva-violet);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.stat-badge.success {
    background: rgba(0, 155, 138, 0.1);
    color: var(--viva-teal);
}

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

.stat-badge.error {
    background: rgba(211, 47, 47, 0.1);
    color: var(--viva-error);
}

/* Flex utilities */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* Text utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--viva-gray-mid); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

/* Responsive design */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .sidebar-header {
        padding: 0.75rem 1rem;
        border-bottom: none;
    }

    .sidebar-nav {
        flex: 1;
        flex-direction: row;
        padding: 0;
        gap: 0.25rem;
    }

    .nav-item {
        padding: 0.5rem 0.75rem;
        border-bottom: 3px solid transparent;
        border-left: none;
    }

    .nav-item.active {
        border-left: none;
        border-bottom-color: var(--viva-yellow);
        background: none;
    }

    .nav-label {
        display: none;
    }

    /* Keep user menu accessible on mobile: collapse to avatar + sign-out pill */
    .sidebar-footer {
        padding: 0.5rem 0.75rem;
        border-top: none;
        border-left: 1px solid rgba(255, 255, 255, 0.15);
        background: transparent;
    }

    .sidebar-footer .user-info {
        gap: 0.5rem;
    }

    .sidebar-footer .user-avatar,
    .sidebar-footer .user-avatar-placeholder {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    /* Name is too long for the compact bar; show only the sign-out pill. */
    .sidebar-footer .user-name {
        display: none;
    }

    .sidebar-footer .user-logout {
        padding: 0.25rem 0.5rem;
        color: var(--viva-white);
        background: rgba(255, 255, 255, 0.1);
        border-radius: var(--viva-radius-sm);
        font-size: 0.75rem;
    }

    .sidebar-footer .user-logout:hover {
        background: rgba(255, 255, 255, 0.2);
        text-decoration: none;
    }

    .main-content {
        margin-left: 0;
    }

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

    .container.two-col {
        grid-template-columns: 1fr;
    }

    .container.three-col {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 1rem;
    }

    .flex-between {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .card-header {
        flex-direction: column;
    }

    .sidebar-brand {
        font-size: 1rem;
    }
}
