/* Tergomedia Invoice Management - Complete Styles */

/* ============================================
   VARIABLES
   ============================================ */
:root {
    --tg-black: #151515;
    --tg-yellow: #f9ca00;
    --tg-gray: #2a2a2a;
}

/* ============================================
   BASE STYLES
   ============================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--tg-black);
}

.bg-pattern {
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
}

/* ============================================
   MODAL STYLES
   ============================================ */
.modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    padding-top: 2rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-container {
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: auto;
    position: relative;
}

.modal-container::-webkit-scrollbar {
    width: 8px;
}

.modal-container::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.modal-container::-webkit-scrollbar-thumb {
    background: var(--tg-yellow);
    border-radius: 4px;
}

.modal-container::-webkit-scrollbar-thumb:hover {
    background: #ffd700;
}

body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* CRITICAL FIX: Force all modal inputs to black background */
.modal-container input,
.modal-container select,
.modal-container textarea {
    background-color: rgba(0, 0, 0, 0.3) !important;
    border-color: #666 !important;
    color: white !important;
}

.modal-container input:focus,
.modal-container select:focus,
.modal-container textarea:focus {
    border-color: var(--tg-yellow) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(249, 202, 0, 0.1) !important;
}

.modal-container input::placeholder,
.modal-container textarea::placeholder {
    color: #999 !important;
}

/* Disabled input styling */
.modal-container input:disabled,
.modal-container select:disabled,
.modal-container textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile Modal Fixes */
@media (max-width: 768px) {
    .modal-wrapper {
        align-items: flex-start;
        padding: 0.5rem;
        padding-top: 1rem;
    }
    
    .modal-container {
        max-height: calc(100vh - 2rem);
        margin-top: 0;
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    .modal-container input,
    .modal-container select,
    .modal-container textarea {
        font-size: 16px !important; /* Prevent iOS zoom */
    }
    
    /* Fix modal spacing on mobile */
    .modal-container .px-6 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .modal-container .py-6 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    /* Fix grid layout on mobile */
    .modal-container .grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    
    .modal-container .grid-cols-5 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ============================================
   LOADING STATES
   ============================================ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    border-top-color: var(--tg-yellow);
    animation: spin 1s ease-in-out infinite;
}

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

/* Button Loading State */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button.loading {
    position: relative;
    color: transparent !important;
}

button.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 0.6s linear infinite;
}

/* ============================================
   ANALYTICS - FIX NUMBER OVERFLOW
   ============================================ */
.analytics-stat-box {
    min-width: 0; /* Allow flex items to shrink */
}

.analytics-stat-value {
    font-size: clamp(1.5rem, 4vw, 2.25rem); /* Responsive font size */
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

.analytics-stat-value {
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    word-break: break-word;
}

#profit-cards .text-4xl,
#profit-cards .text-5xl {
    word-break: break-all;
    hyphens: auto;
}

@media (max-width: 768px) {
    #profit-cards .text-4xl,
    #profit-cards .text-5xl {
        font-size: 1.75rem !important;
    }
}

@media (max-width: 768px) {
    .analytics-stat-value {
        font-size: clamp(1.25rem, 3.5vw, 1.875rem);
    }
}

/* For RON which has larger numbers */
@media (max-width: 768px) {
    .analytics-stat-value {
        font-size: clamp(1.25rem, 3.5vw, 1.875rem);
    }
}

@media (max-width: 480px) {
    .analytics-stat-value {
        font-size: clamp(1rem, 3vw, 1.5rem);
    }
}

/* ============================================
   DROPDOWN MENUS
   ============================================ */
.dropdown-container {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    z-index: 100;
}

/* ============================================
   TABLE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
}