/* Base Styles - Shared across all pages */

/* ========================================
   Core Styles
   ======================================== */

body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background 0.5s ease;
}

/* Loading Background Animation */
body.loading-active {
    background: linear-gradient(45deg, #f8f9fa, #e9ecef, #f8f9fa, #e9ecef);
    background-size: 400% 400%;
    animation: subtleGradientShift 4s ease infinite;
}

@keyframes subtleGradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ========================================
   Navigation Bar
   ======================================== */

.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body.iframe-mode .page-header {
    margin-top: 1rem;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: white !important;
    transition: transform 0.2s ease;
}

.navbar-brand:hover {
    transform: translateX(5px);
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    margin: 0 0.25rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.navbar-nav .nav-link:hover {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.navbar-nav .nav-link.active {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* ========================================
   Page Header & Layout
   ======================================== */

.page-header {
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: #2d3748;
}

.page-description {
    font-size: 1rem;
    color: #718096;
}

/* ========================================
   Cards
   ======================================== */

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

/* ========================================
   Breadcrumbs
   ======================================== */

.breadcrumb {
    background-color: transparent;
    padding: 0;
}

.breadcrumb-item a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-item a:hover {
    color: #764ba2;
}

.breadcrumb-item.active {
    color: #6c757d;
}

/* ========================================
   Forms
   ======================================== */

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

.form-select, .form-control {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    transition: all 0.3s ease;
}

.form-select:focus, .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    transform: scale(1.02);
}

.form-text {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.form-check-input {
    cursor: pointer;
    width: 1.2em;
    height: 1.2em;
}

.form-check-input:checked {
    background-color: #667eea;
    border-color: #667eea;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: width 0.6s, height 0.6s, top 0.6s, left 0.6s;
    transform: translate(-50%, -50%);
    z-index: 0;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn > * {
    position: relative;
    z-index: 1;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
}

.btn-primary:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background-color: #6c757d;
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
}

.btn-danger:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(220, 53, 69, 0.3);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Loading Button States */
.btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ========================================
   Tables
   ======================================== */

.table {
    font-size: 0.875rem;
}

.table th {
    background-color: #343a40;
    color: white;
    font-weight: 600;
    border: none;
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    text-align: center;
    vertical-align: middle;
}

.table td {
    padding: 0.5rem;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6;
    text-align: center;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.025);
}

.table-hover tbody tr {
    transition: all 0.2s ease;
}

.table-hover tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.1) !important;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.table-responsive {
    max-height: 600px;
    overflow-y: auto;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
}

/* Custom scrollbar for table */
.table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Row selection highlight */
tr.selected {
    background-color: rgba(102, 126, 234, 0.2) !important;
}

/* Currency formatting */
.currency {
    text-align: right !important;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

/* ========================================
   Pagination
   ======================================== */

.pagination .page-link {
    color: #667eea;
    border-color: #dee2e6;
    border-radius: 0.375rem;
    margin: 0 0.125rem;
}

.pagination .page-item.active .page-link {
    background-color: #667eea;
    border-color: #667eea;
}

.pagination .page-link:hover {
    color: #495057;
    background-color: #e9ecef;
    border-color: #dee2e6;
}

/* ========================================
   Status Indicators
   ======================================== */

.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-active, .status-sent {
    background-color: #28a745;
    color: #28a745;
    font-weight: 600;
}

.status-inactive, .status-not-sent {
    background-color: #dc3545;
    color: #dc3545;
    font-weight: 600;
}

.status-pending {
    background-color: #ffc107;
}

.positive {
    color: #28a745 !important;
}

.negative {
    color: #dc3545 !important;
}

/* ========================================
   Loading Overlay
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #667eea, #764ba2, #667eea, #764ba2);
    background-size: 400% 400%;
    animation: gradientShift 3s ease infinite;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0.95;
}

.loading-overlay > .text-center {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Enhanced Spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

.enhanced-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.enhanced-spinner::before,
.enhanced-spinner::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    animation: spinnerPulse 2s infinite;
}

.enhanced-spinner::before {
    width: 80px;
    height: 80px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    animation: spinnerRotate 1s linear infinite;
}

.enhanced-spinner::after {
    width: 60px;
    height: 60px;
    top: 10px;
    left: 10px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-bottom-color: white;
    animation: spinnerRotate 1.5s linear infinite reverse;
}

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

@keyframes spinnerPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

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

/* Loading Text Animation */
.loading-text {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 2rem auto 0 auto;
    text-align: center;
    animation: textPulse 2s ease-in-out infinite;
    width: 100%;
}

@keyframes textPulse {
    0%, 100% { opacity: 1; transform: translateY(0); }
    50% { opacity: 0.7; transform: translateY(-5px); }
}

/* Loading Progress Bar */
.loading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: translateX(-100%);
    animation: progressSlide 2s ease-in-out infinite;
    z-index: 10000;
}

@keyframes progressSlide {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0%); }
    100% { transform: translateX(100%); }
}

/* ========================================
   Floating Particles Animation
   ======================================== */

.loading-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    animation: float 4s infinite linear;
}

.particle:nth-child(1) { left: 5%; animation-delay: 0s; width: 6px; height: 6px; }
.particle:nth-child(2) { left: 15%; animation-delay: 0.5s; width: 10px; height: 10px; }
.particle:nth-child(3) { left: 25%; animation-delay: 1s; width: 8px; height: 8px; }
.particle:nth-child(4) { left: 35%; animation-delay: 1.5s; width: 12px; height: 12px; }
.particle:nth-child(5) { left: 45%; animation-delay: 2s; width: 7px; height: 7px; }
.particle:nth-child(6) { left: 55%; animation-delay: 2.5s; width: 9px; height: 9px; }
.particle:nth-child(7) { left: 65%; animation-delay: 3s; width: 11px; height: 11px; }
.particle:nth-child(8) { left: 75%; animation-delay: 3.5s; width: 8px; height: 8px; }
.particle:nth-child(9) { left: 85%; animation-delay: 0.2s; width: 10px; height: 10px; }
.particle:nth-child(10) { left: 95%; animation-delay: 1.2s; width: 6px; height: 6px; }
.particle:nth-child(11) { left: 12%; animation-delay: 0.8s; width: 5px; height: 5px; }
.particle:nth-child(12) { left: 22%; animation-delay: 1.3s; width: 9px; height: 9px; }
.particle:nth-child(13) { left: 32%; animation-delay: 1.8s; width: 7px; height: 7px; }
.particle:nth-child(14) { left: 42%; animation-delay: 2.3s; width: 11px; height: 11px; }
.particle:nth-child(15) { left: 52%; animation-delay: 2.8s; width: 8px; height: 8px; }

@keyframes float {
    0% { transform: translateY(100vh) rotate(0deg) scale(0.5); opacity: 0; }
    10% { opacity: 1; transform: translateY(90vh) rotate(36deg) scale(1); }
    90% { opacity: 1; transform: translateY(10vh) rotate(324deg) scale(1); }
    100% { transform: translateY(-10vh) rotate(360deg) scale(0.5); opacity: 0; }
}

/* ========================================
   Skeleton Loading
   ======================================== */

.shimmer-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton-row {
    height: 20px;
    border-radius: 4px;
    margin: 2px 0;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-loading-row {
    animation: skeletonFade 1.5s ease-in-out infinite;
}

@keyframes skeletonFade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   Alerts
   ======================================== */

.alert {
    border-radius: 8px;
    border: none;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
    .page-title {
        font-size: 1.5rem;
    }
    
    .table {
        font-size: 0.75rem;
    }
    
    .table th,
    .table td {
        padding: 0.25rem;
    }
}
