/* Splittify - Premium Design System */

:root {
    /* Splittify Brand Colors */
    --primary-blue: #3B82F6;
    --secondary-blue: #1E40AF;
    --accent-orange: #FB923C;
    --light-blue: #DBEAFE;
    --background-gradient: linear-gradient(135deg, #E0F2FE 0%, #BFDBFE 100%);
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --success-green: #10B981;
    --danger-red: #EF4444;
    --shadow-soft: 0 4px 20px rgba(59, 130, 246, 0.1);
    --shadow-hover: 0 8px 30px rgba(59, 130, 246, 0.15);
    --border-radius: 16px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --splittify-gradient: linear-gradient(135deg, #3B82F6 0%, #FB923C 100%);
}

/* Splittify Gradient Text */
.gradient-text {
    background: var(--splittify-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    font-weight: 700;
}

/* Smooth global styles */
* {
    transition: var(--transition-smooth);
}

body {
    background: var(--background-gradient);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Premium Card Design */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
}

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

/* Premium Buttons */
.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 12px 24px;
    border: none;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-green), #059669);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent-orange), #F97316);
    color: white;
}

/* Navbar Premium Design */
.navbar {
    background: var(--card-bg) !important;
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-soft);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary-blue) !important;
}

/* Premium Table Design */
.table {
    background: transparent;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table thead th {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    color: white;
    border: none;
    font-weight: 600;
    padding: 16px;
}

.table tbody tr {
    background: rgba(255, 255, 255, 0.5);
    transition: var(--transition-smooth);
}

.table tbody tr:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.01);
}

.table tbody td {
    padding: 16px;
    border: none;
    vertical-align: middle;
}

/* Premium Badges */
.badge {
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 600;
}

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

.badge.bg-secondary {
    background: var(--text-secondary) !important;
}

.badge.bg-success {
    background: var(--success-green) !important;
}

/* Avatar Design */
.avatar-circle {
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-orange));
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: var(--transition-smooth);
}

.avatar-circle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* Premium Components */
.premium-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.8));
    border: 2px solid rgba(59, 130, 246, 0.1);
}

.premium-header-gradient {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue)) !important;
    border: none;
}

.premium-choice-card {
    border: 2px solid rgba(59, 130, 246, 0.2);
    overflow: hidden;
}

.premium-button {
    background: linear-gradient(135deg, var(--accent-orange), #F97316);
    border: none;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.premium-button:hover {
    background: linear-gradient(135deg, #F97316, #EA580C);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(251, 146, 60, 0.4);
}

/* Total Amount Display */
.total-display {
    background: linear-gradient(135deg, var(--success-green), #059669);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

/* OCR Badge */
.ocr-badge {
    background: linear-gradient(135deg, var(--success-green), #059669);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Action Buttons */
.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    border: none;
}

.action-btn-success {
    background: linear-gradient(135deg, var(--success-green), #059669);
    color: white;
}

.action-btn-danger {
    background: linear-gradient(135deg, var(--danger-red), #DC2626);
    color: white;
}

.action-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Smooth loading states */
.loading {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Premium animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced form controls */
.form-control {
    border-radius: 12px;
    border: 2px solid rgba(59, 130, 246, 0.1);
    padding: 12px 16px;
    transition: var(--transition-smooth);
    background: rgba(255, 255, 255, 0.8);
}

.form-control:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: white;
}

/* Split expense specific styles */
.split-participant-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 16px;
    backdrop-filter: blur(10px);
}

.split-summary-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.split-input-container .form-control:disabled {
    background-color: rgba(255, 255, 255, 0.05);
    opacity: 0.5;
}

.calculated-amount {
    font-size: 0.75rem;
    font-weight: 600;
    display: block;
}

.btn-check:checked + .btn-outline-light {
    background-color: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

/* Full width mobile optimization for iPhone 16 Pro Max */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .col-12, .col-md-4, .col-md-8, .col-lg-3, .col-lg-9 {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    
    body {
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden;
    }
    
    /* Ensure cards use full width */
    .card {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Remove Bootstrap container padding on mobile */
    .container {
        padding-left: 8px !important;
        padding-right: 8px !important;
        max-width: 100% !important;
    }
}

/* Avatar circles for users */
.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bs-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.avatar-circle-lg {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--bs-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 24px;
}

/* PWA specific styles */
@media (display-mode: standalone) {
    body {
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }
    
    .navbar {
        padding-top: env(safe-area-inset-top);
    }
}

/* Mobile responsiveness improvements */
@media (max-width: 768px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .btn {
        font-size: 14px;
    }
    
    .table-responsive {
        font-size: 14px;
    }
    
    /* Stack form inputs on mobile */
    .row .col-md-3,
    .row .col-md-4,
    .row .col-md-6 {
        margin-bottom: 1rem;
    }
    
    /* Better touch targets */
    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Improve modal sizing on mobile */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    /* Receipt upload mobile optimization */
    .receipt-upload-container {
        margin-bottom: 1rem;
    }
    
    .receipt-upload-container .btn {
        touch-action: manipulation;
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem 1rem;
    }
    
    .receipt-upload-container .input-group .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Currency and amount styling */
.currency-display {
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

/* Receipt preview styling */
#receipt-preview img {
    border-radius: 0.375rem;
    border: 2px dashed var(--bs-border-color);
    padding: 0.5rem;
}

/* Receipt crop overlay */
.crop-overlay {
    user-select: none;
    -webkit-user-select: none;
}

.crop-handle {
    transition: transform 0.2s ease;
}

.crop-handle:hover {
    transform: scale(1.2);
    cursor: grab;
}

.crop-handle:active {
    cursor: grabbing;
    transform: scale(1.1);
}

/* Mobile touch improvements */
@media (max-width: 768px) {
    .crop-handle {
        width: 24px !important;
        height: 24px !important;
        border-width: 4px !important;
    }
    
    .crop-overlay {
        touch-action: none;
    }
}

/* Selection box styling */
.selection-box {
    border-radius: 4px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.3; }
    50% { opacity: 0.1; }
    100% { opacity: 0.3; }
}

/* OCR suggestions styling */
.ocr-suggestion {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-left: 4px solid #2196f3;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    animation: slideInFromRight 0.3s ease-out;
}

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

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

@keyframes slideOutToTop {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-100%);
    }
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    animation: slideInFromTop 0.3s ease-out;
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pwa-installed {
    /* Add specific styles when PWA is installed */
}

.pwa-installed .container {
    padding-top: env(safe-area-inset-top);
}

/* Places search results */
#places-results {
    max-height: 200px;
    overflow-y: auto;
}

#places-results .border-bottom:last-child {
    border-bottom: none !important;
}

/* Settlement page specific styles */
.settlement-summary {
    background: linear-gradient(135deg, var(--bs-success) 0%, var(--bs-info) 100%);
    color: white;
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
}

/* Custom OCR processing spinner */
.spinner-grow {
    animation: ocr-processing 2s ease-in-out infinite;
}

@keyframes ocr-processing {
    0% {
        transform: scale(0.8) rotate(0deg);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(0.8) rotate(360deg);
        opacity: 0.6;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Better focus states for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Expense status indicators */
.expense-confirmed {
    border-left: 4px solid var(--bs-success);
}

.expense-pending {
    border-left: 4px solid var(--bs-warning);
}

/* Custom animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: slideIn 0.3s ease-out;
}

/* PWA and Mobile specific styles */
@media (display-mode: standalone) {
    /* PWA is installed, adjust for status bar */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .navbar {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }
}

/* Mobile viewport fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific fixes */
    body {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
    
    input, select, textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Responsive utilities */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .btn-group-vertical .btn {
        margin-bottom: 0.5rem;
    }
    
    /* Make mobile navigation more touch-friendly */
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1.1rem;
    }
    
    /* Improve form usability on mobile */
    .form-control {
        font-size: 16px;
        min-height: 48px;
    }
    
    .btn {
        min-height: 48px;
        font-size: 1rem;
    }
}

/* Print styles for settlement reports */
@media print {
    .btn,
    .navbar,
    .alert {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .table {
        border-collapse: collapse;
    }
    
    .table th,
    .table td {
        border: 1px solid #000 !important;
    }
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background-color: var(--bs-warning);
    color: var(--bs-dark);
    text-align: center;
    padding: 0.5rem;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* Enhanced form styling */
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: var(--bs-primary);
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* Better button spacing */
.btn + .btn {
    margin-left: 0.5rem;
}

@media (max-width: 576px) {
    .btn + .btn {
        margin-left: 0;
        margin-top: 0.5rem;
    }
    
    .d-flex.gap-2 {
        flex-direction: column;
    }
    
    .d-flex.gap-2 .btn {
        margin: 0;
    }
}

/* Custom badge styling */
.badge {
    font-size: 0.75em;
}

/* Improved table responsiveness */
.table-responsive {
    border-radius: 0.375rem;
}

.table th {
    border-top: none;
    font-weight: 600;
    color: var(--bs-body-color);
}

/* Status indicators */
.status-paid {
    color: var(--bs-success);
}

.status-pending {
    color: var(--bs-warning);
}

.status-overdue {
    color: var(--bs-danger);
}

/* Improved alerts */
.alert {
    border: none;
    border-radius: 0.5rem;
}

.alert-info {
    background-color: rgba(13, 202, 240, 0.1);
    color: var(--bs-info);
}

.alert-success {
    background-color: rgba(25, 135, 84, 0.1);
    color: var(--bs-success);
}

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

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--bs-danger);
}

/* Enhanced mobile camera and cropper interface */
.camera-container {
    position: relative;
    width: 100%;
    max-width: 100vw;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

.camera-view {
    width: 100%;
    height: 70vh;
    object-fit: cover;
    display: block;
}

.photo-preview {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: none;
    flex-direction: column;
}

.photo-preview.active {
    display: flex;
}

.preview-header {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
}

.preview-image-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-handle {
    position: absolute;
    width: 32px;
    height: 32px;
    background: #0d6efd;
    border: 3px solid white;
    border-radius: 50%;
    cursor: grab;
    pointer-events: all;
    transform: translate(-50%, -50%);
    z-index: 10001;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.crop-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
}

.crop-handle.top-left { background: #dc3545; }
.crop-handle.top-right { background: #28a745; }
.crop-handle.bottom-left { background: #ffc107; }
.crop-handle.bottom-right { background: #17a2b8; }

.selection-area {
    position: absolute;
    border: 2px solid #0d6efd;
    background: rgba(13, 110, 253, 0.1);
    pointer-events: none;
    border-radius: 4px;
}

.preview-controls {
    background: rgba(0, 0, 0, 0.9);
    padding: 1rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.preview-controls .btn {
    min-width: 120px;
    font-weight: 600;
    border-radius: 25px;
    padding: 0.75rem 1.5rem;
}

/* Instructions overlay */
.crop-instructions {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 15px;
    font-size: 0.8rem;
    text-align: center;
    z-index: 10002;
    max-width: 90%;
    display: none;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    20%, 80% { opacity: 1; }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .crop-handle {
        width: 40px;
        height: 40px;
    }
    
    .preview-controls {
        flex-direction: column;
        padding: 1rem;
    }
    
    .preview-controls .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    .crop-instructions {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
        max-width: 90%;
    }
}
