/* ============================================================
   D-Print CMS — Custom Styles
   ============================================================ */

:root {
    --dprint-primary: #0071e3;
    --dprint-text: #202020;
    --dprint-bg: #ffffff;
    --dprint-light-bg: #f5f5f7;
    --dprint-border: #d2d2d7;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--dprint-text);
    background: var(--dprint-bg);
    padding-top: 56px;
}

body.admin-bar .navbar {
    top: 32px;
}

body.admin-bar {
    padding-top: 88px;
}

@media (max-width: 782px) {
    body.admin-bar .navbar {
        top: 0;
    }
    body.admin-bar {
        padding-top: 56px;
    }
}

.main-content {
    min-height: calc(100vh - 120px);
}

/* Navbar */
.navbar {
    background: var(--dprint-primary) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.navbar-brand {
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

/* Buttons */
.btn-primary {
    background: var(--dprint-primary);
    border-color: var(--dprint-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: #005bb5;
    border-color: #005bb5;
}

/* Tables */
.table {
    font-size: 0.875rem;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--dprint-primary);
    color: #fff;
    border-color: var(--dprint-primary);
    white-space: nowrap;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 113, 227, 0.04);
}

.table td,
.table th {
    vertical-align: middle;
}

/* Cards */
.card {
    border: 1px solid var(--dprint-border);
    border-radius: 12px;
    overflow: hidden;
}

.card-header {
    font-weight: 600;
}

.shadow-sm {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}

/* Forms */
.form-control:focus,
.form-select:focus {
    border-color: var(--dprint-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 113, 227, 0.15);
}

.form-check-input:checked {
    background-color: var(--dprint-primary);
    border-color: var(--dprint-primary);
}

/* File link */
.file-link {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-link a {
    color: var(--dprint-primary);
    text-decoration: none;
}

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

/* Status badges */
.badge-status {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

.badge-new {
    background: #28a745;
    color: #fff;
}

.badge-in-progress {
    background: #ffc107;
    color: #202020;
}

.badge-done {
    background: #6c757d;
    color: #fff;
}

.badge-for-review {
    background: #17a2b8;
    color: #fff;
}

.badge-approved {
    background: #6610f2;
    color: #fff;
}

/* Sort buttons */
.btn-group .btn.active {
    background: var(--dprint-primary);
    color: #fff;
    border-color: var(--dprint-primary);
}

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

/* Responsive tweaks */
@media (max-width: 768px) {
    body {
        padding-top: 50px;
    }

    .table {
        font-size: 0.72rem;
    }

    .table thead th {
        white-space: normal;
        font-size: 0.65rem;
    }

    .table td,
    .table th {
        padding: 0.35rem 0.3rem;
    }

    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    h2 {
        font-size: 1.15rem;
    }

    .file-link {
        max-width: 100px;
    }

    .file-link code {
        max-width: 70px !important;
    }

    .btn-sm {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    .dprint-toast {
        min-width: auto;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    #reportStats .col-md-3 {
        margin-bottom: 0.5rem;
    }

    #reportStats .card-body {
        padding: 0.75rem;
    }

    #reportStats h2 {
        font-size: 1.1rem;
    }

    #reportStats h6 {
        font-size: 0.75rem;
    }

    .container-fluid.py-4 > .d-flex {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
    }

    .container-fluid.py-4 > .d-flex > .d-flex {
        flex-wrap: wrap;
        justify-content: stretch !important;
    }

    .container-fluid.py-4 > .d-flex .btn-group {
        width: 100%;
    }

    .container-fluid.py-4 > .d-flex .btn-group .btn {
        flex: 1;
        font-size: 0.8rem;
    }

    .container-fluid.py-4 > .d-flex .form-control-sm {
        width: 100% !important;
    }

    #ordersPag .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    #ordersPag .page-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    .nav-link {
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .table {
        font-size: 0.68rem;
    }

    .table td,
    .table th {
        padding: 0.25rem 0.2rem;
    }

    .file-link {
        max-width: 80px;
    }

    .file-link code {
        max-width: 55px !important;
        font-size: 0.65rem;
    }

    #ordersPag .page-link {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
}

/* Print-friendly */
@media print {
    .navbar,
    .btn,
    .form-check,
    footer {
        display: none !important;
    }

    body {
        padding-top: 0;
    }

    .table thead th {
        background: #fff !important;
        color: #000 !important;
    }
}

/* Toast notifications */
.dprint-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Checkbox column */
td:first-child,
th:first-child {
    text-align: center;
}

/* Design text cells (task / technical spec) */
.design-cell {
    max-width: 260px;
}

.design-cell-content {
    max-height: 3em;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.design-cell.expanded {
    max-width: 420px;
}

.design-cell.expanded .design-cell-content {
    max-height: none;
}

.btn-expand-text {
    font-size: 0.7rem;
    line-height: 1;
    text-decoration: none;
    margin-top: 2px;
}

.btn-expand-text:hover {
    text-decoration: underline;
}

/* List group on materials page */
.list-group-item {
    font-size: 0.875rem;
}
