/**
 * Renewals Management System - Main Stylesheet
 * Custom styles for the PWA application
 */

/* ============================================================================
   CSS Variables
   ============================================================================ */
:root {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --header-height: 60px;
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --transition-speed: 0.3s;
}

/* ============================================================================
   Base Styles
   ============================================================================ */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f4f6f9;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--primary-hover);
}

/* ============================================================================
   Sidebar Styles
   ============================================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    z-index: 1000;
    transition: transform var(--transition-speed) ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.sidebar-brand span {
    color: #2c3e50;
    font-weight: 700;
    font-size: 1.15rem;
}

.sidebar-brand img {
    height: 36px;
    width: 36px;
    margin-right: 0.75rem;
}

.sidebar-brand h5 {
    color: #2c3e50;
    margin: 0;
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section-title {
    padding: 0.75rem 1.5rem 0.5rem 1.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6c757d;
    font-weight: 700;
    margin-top: 0.75rem;
    border-top: 1px solid #e9ecef;
}

.nav-section {
    padding: 0.75rem 1.5rem 0.5rem 1.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6c757d;
    font-weight: 700;
    margin-top: 0.75rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: #495057;
    font-weight: 500;
    transition: all var(--transition-speed);
    border-left: 3px solid transparent;
    margin: 0.15rem 0.75rem;
    border-radius: 6px;
}

.sidebar-nav .nav-link:hover {
    background: #e9ecef;
    color: #212529;
}

.sidebar-nav .nav-link.active {
    background: #dee2e6;
    color: #212529;
    font-weight: 600;
    border-left-color: var(--primary-color);
}

.sidebar-nav .nav-link i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 0.75rem;
    color: #6c757d;
}

.sidebar-nav .nav-link:hover i,
.sidebar-nav .nav-link.active i {
    color: var(--primary-color);
}

/* Sidebar toggle for mobile */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform var(--transition-speed);
}

.sidebar-toggle:hover {
    transform: scale(1.1);
}

/* Sidebar close button for mobile */
.sidebar-close {
    color: #6c757d;
    padding: 0;
    font-size: 1.25rem;
}

.sidebar-close:hover {
    color: #212529;
}

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

    .sidebar.show,
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

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

    .sidebar-backdrop,
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-backdrop.show,
    .sidebar.mobile-open ~ .sidebar-overlay {
        display: block;
    }
}

/* ============================================================================
   Main Content Area
   ============================================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-speed);
}

.top-navbar {
    background: #fff;
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.content-wrapper {
    padding: 1.5rem;
}

/* ============================================================================
   Cards and Stats
   ============================================================================ */
.stats-card {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    border: none;
    height: 100%;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stats-card .stats-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stats-card .stats-icon.bg-primary-light {
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
}

.stats-card .stats-icon.bg-warning-light {
    background: rgba(255, 193, 7, 0.1);
    color: #d4a106;
}

.stats-card .stats-icon.bg-danger-light {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

.stats-card .stats-icon.bg-success-light {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
}

.stats-card .stats-icon.bg-info-light {
    background: rgba(23, 162, 184, 0.1);
    color: var(--info-color);
}

.stats-card .stats-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark-color);
}

.stats-card .stats-label {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

/* ============================================================================
   Table Styles
   ============================================================================ */
.table-container {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-container .table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #495057;
    padding: 0.875rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
}

.table tbody tr:hover {
    background-color: #f8f9fc;
}

/* ============================================================================
   Badge Styles
   ============================================================================ */
.badge-status {
    padding: 0.35rem 0.65rem;
    font-weight: 500;
    font-size: 0.75rem;
}

.badge-active {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.badge-expired {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

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

.days-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
}

.days-badge.critical {
    background: linear-gradient(135deg, #ff6b6b 0%, #dc3545 100%);
    color: #fff;
}

.days-badge.urgent {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #212529;
}

.days-badge.soon {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: #fff;
}

.days-badge.normal {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: #fff;
}

/* ============================================================================
   Form Styles
   ============================================================================ */
.form-control, .form-select {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    padding: 0.625rem 0.875rem;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(67, 97, 238, 0.15);
}

.form-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}

.input-group-text {
    background: #f8f9fa;
    border-color: #ced4da;
}

/* ============================================================================
   Button Styles
   ============================================================================ */
.btn {
    padding: 0.5rem 1rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all var(--transition-speed);
}

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

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

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
}

/* ============================================================================
   Page Header
   ============================================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark-color);
    margin: 0;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
}

.breadcrumb-item a {
    color: var(--secondary-color);
}

.breadcrumb-item.active {
    color: var(--dark-color);
}

/* ============================================================================
   Search Box
   ============================================================================ */
.search-box {
    position: relative;
}

.search-box .form-control {
    padding-left: 2.5rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.search-box .form-control:focus {
    background: #fff;
}

.search-box .search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-color);
}

/* ============================================================================
   Card Styles
   ============================================================================ */
.card {
    border: none;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* ============================================================================
   Alert Styles
   ============================================================================ */
.alert {
    border: none;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
}

.alert-success {
    background: rgba(40, 167, 69, 0.1);
    color: #155724;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    color: #721c24;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
}

.alert-info {
    background: rgba(23, 162, 184, 0.1);
    color: #0c5460;
}

/* ============================================================================
   Login Page
   ============================================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
    text-align: center;
    color: #fff;
}

.login-header img {
    width: 72px;
    height: 72px;
    margin-bottom: 1rem;
}

.login-header h4 {
    margin: 0;
    font-weight: 600;
}

.login-body {
    padding: 2rem;
}

.login-body .btn-primary {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

/* ============================================================================
   Filter Panel
   ============================================================================ */
.filter-panel {
    background: #fff;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.filter-panel .row {
    align-items: flex-end;
}

/* ============================================================================
   Empty State
   ============================================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state i {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.empty-state h5 {
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #adb5bd;
}

/* ============================================================================
   Dropdown User Menu
   ============================================================================ */
.user-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    color: var(--dark-color);
}

.user-dropdown .dropdown-toggle:hover {
    background: #e9ecef;
}

.user-dropdown .dropdown-toggle::after {
    margin-left: 0.5rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

/* ============================================================================
   Pagination
   ============================================================================ */
.pagination {
    margin: 0;
}

.page-link {
    color: var(--primary-color);
    border-color: #dee2e6;
    padding: 0.5rem 0.875rem;
}

.page-link:hover {
    color: var(--primary-hover);
    background: #e9ecef;
}

.page-item.active .page-link {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* ============================================================================
   Utility Classes
   ============================================================================ */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

.hover-shadow:hover {
    box-shadow: var(--shadow-md);
}

/* ============================================================================
   Responsive Adjustments
   ============================================================================ */
@media (max-width: 767.98px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-card {
        margin-bottom: 1rem;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    .filter-panel .col-md-2,
    .filter-panel .col-md-3 {
        margin-bottom: 0.75rem;
    }
}

/* ============================================================================
   Print Styles
   ============================================================================ */
@media print {
    .sidebar,
    .sidebar-toggle,
    .top-navbar,
    .btn,
    .pagination {
        display: none !important;
    }

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

    .content-wrapper {
        padding: 0;
    }

    .table-container {
        box-shadow: none;
    }
}