/* Home page and dashboard blocks for consistency */
.lead {
    font-size: 1.1rem;
    color: #555;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.card {
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    margin-bottom: 0;
}

.card h3 {
    margin-top: 0;
    color: #007bff;
}

.card p {
    color: #666;
}

.card .btn-primary {
    display: inline-block;
    margin-top: 1rem;
}

.stats-card {
    margin-top: 3rem;
    padding: 2rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

.stat-block {
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
}
.stat-green { color: #28a745; }
.stat-blue { color: #007bff; }
.stat-yellow { color: #ffc107; }
.stat-cyan { color: #17a2b8; }
.stat-label {
    color: #666;
    margin-top: 0.5rem;
}
/* Global main padding for all pages (matches Home page test) */
main {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
    padding-top: 2rem !important;
}

@media (max-width: 768px) {
    main {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        padding-top: 1rem !important;
    }
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: #f5f5f5;
}

/* Remove old nav styles - now handled in base.html */

.overlay {
    display: none;
}

/* Main element styles are in base.html */

.detail-container {
    width: 100%;
    margin: 0;
}

.detail-container h2 {
    margin: 0 0 2rem 0;
    padding: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: #333;
}

.section {
    margin-top: 2rem;
}

.section:first-of-type {
    margin-top: 1rem;
}

.link-list {
    list-style: none;
    padding-left: 0;
    margin: 0.5rem 0 0 0;
}

.link-list li {
    margin-bottom: 0.5rem;
}

.link-list a {
    color: #007bff;
    text-decoration: none;
}

.link-list a:hover {
    text-decoration: underline;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background: #f0f0f0;
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    background: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.header-actions h2 {
    color: #212529;
    margin: 0;
}

.filter-container {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-container label {
    font-weight: bold;
}

.filter-container select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.btn-primary {
    background: #007bff;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: inline-block;
    font-family: Arial, sans-serif;
    font-size: 1rem;
    font-weight: normal;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: inline-block;
    margin-left: 0.5rem;
    font-family: Arial, sans-serif;
    font-size: 1rem;
    font-weight: normal;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-danger {
    background: #dc3545;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: inline-block;
    margin-left: 0.5rem;
    font-family: Arial, sans-serif;
    font-size: 1rem;
    font-weight: normal;
}

.btn-danger:hover {
    background: #c82333;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: Arial, sans-serif;
}

.form-group input[type="text"][id$="_display"] {
    text-align: right;
}

.form-group input[type="checkbox"] {
    width: auto;
}

.form-actions {
    margin-top: 2rem;
}

.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Toast Notifications */
.toast {
    background: white;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 400px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease-in-out;
    border-left: 4px solid #28a745;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(400px);
}

.toast-success {
    border-left-color: #28a745;
    background: linear-gradient(to right, #f0fff4 0%, white 20%);
}

.toast-error {
    border-left-color: #dc3545;
    background: linear-gradient(to right, #fff5f5 0%, white 20%);
}

.toast-warning {
    border-left-color: #ffc107;
    background: linear-gradient(to right, #fffef0 0%, white 20%);
}

.toast-info {
    border-left-color: #17a2b8;
    background: linear-gradient(to right, #f0f9ff 0%, white 20%);
}

.expiring {
    color: #dc3545;
    font-weight: bold;
}

table a {
    color: #007bff;
    text-decoration: none;
}

table a:hover {
    text-decoration: underline;
}

.detail-row {
    display: flex;
    padding: 1rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.detail-row label {
    font-weight: bold;
    width: 200px;
    flex-shrink: 0;
}

.detail-row span {
    flex: 1;
}

.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px;
}

.sortable:hover {
    background: #e8e8e8;
}

.sortable::after {
    content: '⇅';
    position: absolute;
    right: 8px;
    opacity: 0.3;
}

.sortable.asc::after {
    content: '▲';
    opacity: 1;
}

.sortable.desc::after {
    content: '▼';
    opacity: 1;
}

.inactive-contract {
    color: #dc3545;
}

.inactive-contract a {
    color: #dc3545;
}

.flag-icon {
    width: 24px;
    height: 16px;
    vertical-align: middle;
    margin-right: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 2px;
}

/* ============================================
   MODAL STYLES
   ============================================ */

/* Centered modal system - working solution */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
}

.modal.modal-open {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
}

.btn-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.btn-close:hover {
    color: #000;
}

/* Modal inner container - replaces inline styles on modal content divs */
.modal-inner {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-inner-sm { min-width: 300px; max-width: 500px; }
.modal-inner-md { min-width: 500px; max-width: 600px; }
.modal-inner-lg { min-width: 500px; max-width: 700px; }

.modal-title {
    margin: 0 0 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.modal-close-btn:hover {
    color: #333;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ============================================
   RESPONSIVE CSS - MOBILE FIRST APPROACH
   ============================================ */

/* Tablet Breakpoint - 768px and below */
@media (max-width: 768px) {
    /* Tables - Enable horizontal scrolling */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border: 1px solid #dee2e6;
        border-radius: 4px;
        margin-bottom: 1rem;
    }
    
    table {
        font-size: 0.9rem;
        min-width: 600px; /* Prevent table from getting too narrow */
    }
    
    th, td {
        padding: 0.5rem !important;
        white-space: nowrap;
    }
    
    /* Header Actions - Stack on mobile */
    .header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }
    
    .header-actions h2 {
        text-align: center;
    }
    
    .header-actions .btn-primary,
    .header-actions .btn-secondary {
        width: 100%;
        margin: 0;
    }
    
    /* Filter Container - Stack vertically */
    .filter-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .filter-container label {
        margin-bottom: 0.25rem;
    }
    
    .filter-container select {
        width: 100%;
    }
    
    /* Forms - Full width inputs */
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Button Groups - Stack vertically */
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group .btn,
    .btn-group .btn-primary,
    .btn-group .btn-secondary,
    .btn-group .btn-danger {
        width: 100%;
        margin: 0;
    }
    
    /* Form Actions - Stack buttons */
    .form-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-actions .btn,
    .form-actions .btn-primary,
    .form-actions .btn-secondary,
    .form-actions .btn-danger {
        width: 100%;
        margin: 0 !important;
    }
    
    /* Cards - Responsive grid */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 1.5rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    /* Stats Grid - 2 columns on tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    /* Detail Rows - Stack on mobile */
    .detail-row {
        flex-direction: column;
        padding: 0.75rem 0;
    }
    
    .detail-row label {
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    /* Modals */
    .modal-content {
        width: 95%;
        max-width: 100%;
        max-height: 95vh;
        border-radius: 8px;
    }

    .modal-header {
        padding: 0.75rem 1rem;
    }

    .modal-header h2,
    .modal-header h3 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 1rem;
    }
    
    /* Alert boxes */
    .alert {
        font-size: 0.9rem;
        padding: 0.75rem;
    }
}

/* Mobile Breakpoint - 480px and below */
@media (max-width: 480px) {
    /* Typography - Smaller on phone */
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    /* Tables - Even smaller on phone */
    table {
        font-size: 0.85rem;
        min-width: 500px;
    }
    
    th, td {
        padding: 0.4rem !important;
    }
    
    /* Buttons - Full width and larger touch targets */
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        font-size: 0.95rem;
        padding: 0.75rem 1rem;
        min-height: 44px; /* iOS recommended touch target */
    }
    
    /* Stack action buttons vertically */
    .btn-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .btn-toolbar .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Stats Grid - Single column on phone */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    /* Navigation Brand - Smaller logo */
    .nav-brand img {
        height: 32px;
    }
    
    .nav-brand h1 {
        font-size: 1rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 98%;
        max-height: 98vh;
    }

    .modal-header {
        padding: 0.5rem 0.75rem;
    }

    .modal-header h2,
    .modal-header h3 {
        font-size: 1rem;
    }

    .modal-body {
        padding: 0.75rem;
    }
}

/* Large Desktop - 1200px and above */
@media (min-width: 1200px) {
    /* Wider containers for large screens */
    .container {
        max-width: 1400px;
    }
    
    /* More columns in card grid */
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Stats grid with 4 columns */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Quill editor content - preserve nested list formatting */
.ql-editor ol,
.ql-editor ul,
.clause-content ol,
.clause-content ul {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

/* First level: decimal (1, 2, 3) */
.ql-editor ol,
.clause-content ol {
    list-style-type: decimal;
}

/* Second level: lower-alpha (a, b, c) */
.ql-editor ol ol,
.clause-content ol ol {
    list-style-type: lower-alpha;
}

/* Third level: lower-roman (i, ii, iii) */
.ql-editor ol ol ol,
.clause-content ol ol ol {
    list-style-type: lower-roman;
}

/* Fourth level: decimal again */
.ql-editor ol ol ol ol,
.clause-content ol ol ol ol {
    list-style-type: decimal;
}

.ql-editor li,
.clause-content li {
    padding-left: 0.5em;
    margin: 0.25em 0;
}

/* Ensure list items display properly */
.ql-editor li:not(.ql-direction-rtl),
.clause-content li {
    padding-left: 0.5em;
}

/* ============================================
   Breadcrumb Navigation (Reusable Component)
   ============================================ */
.breadcrumbs {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: transparent;
    line-height: 1;
}

.breadcrumbs a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumbs a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.breadcrumbs .separator {
    color: #adb5bd;
    margin: 0 0.25rem;
}

.breadcrumbs .current {
    color: #495057;
    font-weight: 500;
}

/* ============================================
   Icon-Only Buttons (Reusable Component)
   ============================================ */
.btn-icon-only {
    background: white;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    text-decoration: none;
}

.btn-icon-only:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-icon-only.primary {
    color: #007bff;
    border-color: #007bff;
}

.btn-icon-only.primary:hover {
    background: #007bff;
    color: white;
}

.btn-icon-only.success {
    color: #28a745;
    border-color: #28a745;
}

.btn-icon-only.success:hover {
    background: #28a745;
    color: white;
}

.btn-icon-only.danger {
    color: #dc3545;
    border-color: #dc3545;
}

.btn-icon-only.danger:hover {
    background: #dc3545;
    color: white;
}

.btn-icon-only.secondary {
    color: #6c757d;
    border-color: #6c757d;
}

.btn-icon-only.secondary:hover {
    background: #6c757d;
    color: white;
}

.btn-icon-only:disabled,
.btn-icon-only.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

.btn-icon-only:disabled:hover,
.btn-icon-only.disabled:hover {
    background: white;
    border-color: #dee2e6;
    transform: none;
}

/* Tooltip for icon-only buttons */
.btn-icon-only[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 0.5rem 0.75rem;
    background: #333;
    color: white;
    font-size: 0.75rem;
    white-space: nowrap;
    border-radius: 4px;
    z-index: 1000;
    pointer-events: none;
}

.btn-icon-only[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    border: 6px solid transparent;
    border-top-color: #333;
    z-index: 1000;
    pointer-events: none;
}

/* ============================================
   Page Header (Reusable Component)
   Alternative to .header-actions with same styling
   ============================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    background: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.page-header h2 {
    margin: 0;
    color: #212529;
}
