/**
 * Custom Theme for eDnevnik
 */

:root {
    --primary: #2c3e50;
    --primary-dark: #1a252f;
    --secondary: #34495e;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --light: #ecf0f1;
    --dark: #2c3e50;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow-x: hidden;
    background: #f8f9fa;
    margin: 0;
    padding: 0;
}

html {
    overflow-x: hidden;
}

/* ==================== LOADING SPINNER ==================== */
.app-spinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.app-spinner .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* ==================== LOGIN VIEW ==================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 1rem;
}

.login-card {
    background: white;
    padding: 3rem 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 420px;
    width: 100%;
}

@media (max-width: 576px) {
    .login-card {
        padding: 2rem 1.5rem;
        max-width: 100%;
        margin: 0 1rem;
    }

    .login-card h1 {
        font-size: 1.5rem;
    }

    .brand-logo {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
}

.brand-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: var(--primary);
    font-size: 2.5rem;
}

.brand-logo:has(i) {
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: white;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.login-card h1 {
    text-align: center;
    color: var(--primary);
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 2rem;
}

.login-card .form-label {
    font-weight: 500;
    color: #555;
}

.login-card .form-control {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #ddd;
}

.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(44, 62, 80, 0.15);
}

.login-card .btn-primary {
    padding: 0.75rem;
    font-weight: 500;
    border-radius: 0.5rem;
}

/* ==================== APP SHELL ==================== */
.app-shell {
    min-height: 100vh;
    background: #f8f9fa;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    min-width: 0;
    background: #f8f9fa;
    padding: 30px;
    overflow-y: auto;
    height: 100vh;
}

/* ==================== TOPBAR (Mobile) ==================== */
.topbar {
    height: 60px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo-mini {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.25rem;
}

.logo-mini:has(i) {
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: white;
}

.logo-mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
}

/* Smooth scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    width: 100%;
    color: white;
}

.sidebar .brand {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar .logo {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

.sidebar .logo:has(i) {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar .logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Offcanvas logo — mirrors .sidebar .logo (offcanvas is not inside .sidebar) */
#logoOffcanvas {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

#logoOffcanvas:has(i) {
    background: rgba(255, 255, 255, 0.15);
}

#logoOffcanvas img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.sidebar .platform-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.sidebar .school-name {
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
}

/* Navigation */
.nav-section {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

.nav-section .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.875rem 1.25rem;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-section .nav-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.nav-section .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-section .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 500;
}

/* Sidebar Bottom */
.sidebar-bottom {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.btn-logout {
    width: 100%;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
}

/* ==================== MAIN CONTENT ==================== */
.app-content {
    background: #f8f9fa;
    min-height: 100vh;
}

#page-content {
    max-width: 1400px;
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 991.98px) {
    .app-wrapper {
        flex-direction: column;
    }

    .app-main {
        padding: 20px 15px;
        width: 100%;
        height: auto;
        min-height: calc(100vh - 60px);
    }

    /* Mobile offcanvas sidebar */
    #sidebarOffcanvas {
        width: 280px;
        border: none;
        background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    }

    #sidebarOffcanvas .sidebar-inner {
        min-height: 100%;
        height: auto;
        overflow-y: auto;
    }

    /* Allow scrolling in offcanvas */
    #sidebarOffcanvas .offcanvas-body {
        padding: 0;
        overflow-y: auto;
    }

    /* Prevent body scroll when offcanvas is open */
    body.offcanvas-open {
        overflow: hidden;
    }

    /* Smooth backdrop */
    .offcanvas-backdrop {
        background-color: rgba(0, 0, 0, 0.5);
    }
}

/* Desktop specific */
@media (min-width: 992px) {
    .topbar {
        display: none;
    }
}

/* ==================== UTILITIES ==================== */
.hover-shadow {
    transition: box-shadow 0.3s;
}

.hover-shadow:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

/* ==================== BOOTSTRAP OVERRIDES ==================== */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

/* Card enhancements */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-header {
    background: white;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

/* Table improvements */
.table-hover tbody tr:hover {
    background-color: rgba(44, 62, 80, 0.03);
}

/* Avatar styles */
.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(44, 62, 80, 0.1) !important;
    flex-shrink: 0;
}

.avatar-sm .text-primary {
    color: var(--primary) !important;
    font-weight: 600;
}

/* Bootstrap opacity utilities fix for stat cards */
.bg-primary.bg-opacity-10 {
    background-color: rgba(44, 62, 80, 0.1) !important;
}

.bg-success.bg-opacity-10 {
    background-color: rgba(39, 174, 96, 0.1) !important;
}

.bg-warning.bg-opacity-10 {
    background-color: rgba(243, 156, 18, 0.1) !important;
}

.bg-danger.bg-opacity-10 {
    background-color: rgba(231, 76, 60, 0.1) !important;
}

.bg-info.bg-opacity-10 {
    background-color: rgba(52, 152, 219, 0.1) !important;
}

.bg-secondary.bg-opacity-10 {
    background-color: rgba(52, 73, 94, 0.1) !important;
}

/* Ensure text colors work properly */
.text-success {
    color: var(--success) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-info {
    color: var(--info) !important;
}

.text-secondary {
    color: var(--secondary) !important;
}

/* ==================== BREADCRUMB ==================== */
.breadcrumb {
    flex-wrap: nowrap;
}

.breadcrumb-item {
    min-width: 0;
}

.breadcrumb-item.active {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ==================== GRADES TABLE ==================== */
.grade-add-chip,
.grade-final-chip {
    --bs-btn-padding-y: 0.125rem;
    --bs-btn-padding-x: 0.4rem;
    --bs-btn-font-size: 0.75rem;
    line-height: 1;
    border-style: dashed;
}
