/**
 * SoftSpot Insurance Solution - Custom Styles
 * Bootstrap 5 custom theme and animations
 */

/* ============================================================================
   ROOT VARIABLES
   ============================================================================ */
:root {
    --primary-color: #1890ff;
    --secondary-color: #6c757d;
    --success-color: #52c41a;
    --danger-color: #f5222d;
    --warning-color: #faad14;
    --info-color: #1890ff;
    --dark-color: #001529;
    --light-bg: #f0f2f5;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;

    /* Sidebar colors - can be dynamically overridden */
    --sidebar-bg-start: #1e3a8a;
    --sidebar-bg-mid: #1e40af;
    --sidebar-bg-end: #1e3a8a;
    --sidebar-accent: #60a5fa;
}

/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--light-bg);
    color: #333;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.animate-fadeIn {
    animation: fadeIn 0.5s ease-out;
}

.animate-slideInRight {
    animation: slideInRight 0.5s ease-out;
}

.animate-slideInLeft {
    animation: slideInLeft 0.5s ease-out;
}

.animate-scaleIn {
    animation: scaleIn 0.4s ease-out;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    background: linear-gradient(180deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-mid) 50%, var(--sidebar-bg-end) 100%);
    color: white;
    overflow-y: auto;
    transition: var(--transition);
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

/* Sidebar Header */
.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-header i {
    font-size: 28px;
    color: var(--sidebar-accent);
}

.sidebar-header span {
    font-size: 18px;
    font-weight: 600;
    color: white;
    letter-spacing: -0.5px;
}

/* Sidebar User Section */
.sidebar-user {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.03);
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sidebar-accent) 0%, var(--primary-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
}

.user-avatar i {
    font-size: 32px;
    color: white;
}

.user-info {
    text-align: center;
}

.user-name {
    font-size: 15px;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
}

.user-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 16px 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    margin: 2px 0;
}

.sidebar-nav .nav-link i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: var(--sidebar-accent);
}

.sidebar-nav .nav-link.active {
    background: rgba(96, 165, 250, 0.2);
    color: white;
    border-left-color: var(--sidebar-accent);
    font-weight: 500;
}

/* Sidebar Footer */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: all 0.3s ease;
}

.sidebar-footer .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fca5a5;
}

.sidebar-footer .nav-link i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.sidebar-logo {
    padding: 20px;
    font-size: 20px;
    font-weight: 600;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    transition: var(--transition);
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-menu a.active {
    background: var(--primary-color);
    color: white;
}

.sidebar-menu a i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.main-content {
    margin-left: 260px;
    min-height: 100vh;
    transition: var(--transition);
}

.topbar {
    background: white;
    padding: 15px 30px;
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
}

.content-area {
    padding: 30px;
}

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
    border: none;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-header {
    background: white;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    padding: 15px 20px;
}

.card-body {
    padding: 20px;
}

/* Stats Card */
.stats-card {
    text-align: center;
    padding: 25px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, #40a9ff 100%);
    opacity: 0;
    transition: var(--transition);
    z-index: 0;
}

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

.stats-card:hover {
    color: white !important;
}

.stats-card:hover .stats-icon,
.stats-card:hover .stats-icon i {
    color: white !important;
    transform: scale(1.1) rotate(5deg);
}

.stats-card:hover .stats-value,
.stats-card:hover .stats-label {
    color: white !important;
}

.stats-icon {
    font-size: 48px;
    margin-bottom: 15px;
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

.stats-value {
    font-size: 32px;
    font-weight: 700;
    margin: 10px 0;
    position: relative;
    z-index: 1;
}

.stats-label {
    font-size: 14px;
    opacity: 0.8;
    position: relative;
    z-index: 1;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
    border-radius: 6px;
    padding: 8px 20px;
    font-weight: 500;
    transition: var(--transition);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

/* ============================================================================
   AVATAR
   ============================================================================ */
.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #40a9ff);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
}

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

.btn-primary:hover {
    background: #40a9ff;
    border-color: #40a9ff;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

/* ============================================================================
   TABLES
   ============================================================================ */
.table-wrapper {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.table {
    margin: 0;
}

.table thead {
    background: #fafafa;
}

.table th {
    font-weight: 600;
    color: rgba(0, 0, 0, 0.85);
    border-bottom: 2px solid #f0f0f0;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: #fafafa;
}

.table-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* ============================================================================
   FORMS
   ============================================================================ */
.form-label {
    font-weight: 500;
    margin-bottom: 8px;
    color: rgba(0, 0, 0, 0.85);
}

.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid #d9d9d9;
    padding: 8px 12px;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.form-control:hover, .form-select:hover {
    border-color: var(--primary-color);
}

.input-group-text {
    background: #fafafa;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
}

/* ============================================================================
   BADGES
   ============================================================================ */
.badge {
    padding: 4px 12px;
    font-weight: 500;
    border-radius: 4px;
}

/* ============================================================================
   MODALS
   ============================================================================ */
.modal-content {
    border-radius: 8px;
    border: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid #f0f0f0;
    padding: 20px;
}

.modal-title {
    font-weight: 600;
    font-size: 18px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid #f0f0f0;
    padding: 15px 20px;
}

/* ============================================================================
   AUTHENTICATION PAGES
   ============================================================================ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.auth-card {
    max-width: 450px;
    width: 100%;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo h1 {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 28px;
}

.auth-logo p {
    color: #666;
    margin-top: 5px;
}

/* ============================================================================
   LOADING SPINNER
   ============================================================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    text-align: center;
}

/* ============================================================================
   TOAST CONTAINER
   ============================================================================ */
#toast-container {
    z-index: 10000;
}

/* ============================================================================
   UTILITIES
   ============================================================================ */
.hover-shadow {
    transition: var(--transition);
}

.hover-shadow:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.cursor-pointer {
    cursor: pointer;
}

.no-decoration {
    text-decoration: none;
}

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

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

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

    .content-area {
        padding: 15px;
    }

    .auth-card {
        padding: 30px 20px;
    }
}

/* Sidebar backdrop for mobile */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 900;
}
.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   DARK THEME
   ============================================================================ */
body.dark-theme {
    background-color: #1a1a1a;
    color: #e4e4e4;
}

body.dark-theme .card {
    background-color: #2d2d2d;
    border-color: #404040;
    color: #e4e4e4;
}

body.dark-theme .main-content {
    background-color: #1a1a1a;
}

body.dark-theme .topbar {
    background: #2d2d2d;
    border-bottom-color: #404040;
}

body.dark-theme .sidebar {
    background: #2d2d2d;
    border-right-color: #404040;
}

body.dark-theme .sidebar-brand {
    border-bottom-color: #404040;
}

body.dark-theme .sidebar-menu a {
    color: #b0b0b0;
}

body.dark-theme .sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

body.dark-theme .sidebar-menu a.active {
    background: rgba(24, 144, 255, 0.2);
    color: #1890ff;
}

body.dark-theme .table {
    color: #e4e4e4;
}

body.dark-theme .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.02);
}

body.dark-theme .table > :not(caption) > * > * {
    border-bottom-color: #404040;
}

body.dark-theme .form-control,
body.dark-theme .form-select {
    background-color: #3d3d3d;
    border-color: #404040;
    color: #e4e4e4;
}

body.dark-theme .form-control:focus,
body.dark-theme .form-select:focus {
    background-color: #3d3d3d;
    border-color: #1890ff;
    color: #e4e4e4;
}

body.dark-theme .modal-content {
    background-color: #2d2d2d;
    border-color: #404040;
}

body.dark-theme .modal-header,
body.dark-theme .modal-footer {
    border-color: #404040;
}

body.dark-theme .nav-tabs {
    border-bottom-color: #404040;
}

body.dark-theme .nav-tabs .nav-link {
    color: #b0b0b0;
}

body.dark-theme .nav-tabs .nav-link:hover {
    border-color: #404040 #404040 transparent;
    color: #e4e4e4;
}

body.dark-theme .nav-tabs .nav-link.active {
    background-color: #2d2d2d;
    border-color: #404040 #404040 #2d2d2d;
    color: #1890ff;
}

body.dark-theme .dropdown-menu {
    background-color: #2d2d2d;
    border-color: #404040;
}

body.dark-theme .dropdown-item {
    color: #e4e4e4;
}

body.dark-theme .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

body.dark-theme .text-muted {
    color: #888 !important;
}

body.dark-theme hr {
    border-color: #404040;
    opacity: 1;
}

body.dark-theme .btn-link {
    color: #1890ff;
}

body.dark-theme .btn-outline-primary {
    color: #1890ff;
    border-color: #1890ff;
}

body.dark-theme .btn-outline-primary:hover {
    background-color: #1890ff;
    color: #fff;
}

body.dark-theme .btn-outline-secondary {
    color: #b0b0b0;
    border-color: #404040;
}

body.dark-theme .btn-outline-secondary:hover {
    background-color: #404040;
    color: #e4e4e4;
}

body.dark-theme .btn-outline-danger {
    color: #f5222d;
    border-color: #f5222d;
}

body.dark-theme .btn-outline-danger:hover {
    background-color: #f5222d;
    color: #fff;
}

/* ============================================================================
   PROFILE PAGE STYLES
   ============================================================================ */
.profile-avatar-large {
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-item {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.info-item:last-child {
    border-bottom: none;
}

.info-item label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #8c8c8c;
    margin-bottom: 4px;
}

.info-item p {
    font-size: 1rem;
    color: #262626;
    margin: 0;
}

body.dark-theme .info-item {
    border-bottom-color: #303030;
}

body.dark-theme .info-item label {
    color: #a0a0a0;
}

body.dark-theme .info-item p {
    color: #e4e4e4;
}

/* ============================================================================
   PAGE LOADING OVERLAY
   ============================================================================ */
#pageLoadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #001f3f 0%, #003366 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    transition: opacity 0.3s ease;
}

#pageLoadingOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#pageLoadingOverlay .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#pageLoadingOverlay .loading-text {
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    margin-top: 20px;
    text-align: center;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
