/* DaisyCapsule - Mobile-First Styles */

:root {
    --primary: #4a90a4;
    --primary-dark: #3a7a8f;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #e0e0e0;
    --success: #4caf50;
    --error: #f44336;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

#app {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    padding: 1.5rem 0;
}

.logo {
    width: 64px;
    height: 64px;
    margin-bottom: 0.5rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}

.version {
    display: block;
    font-size: 0.7rem;
    color: var(--border);
    margin-top: 0.25rem;
}

/* Tiles Grid */
.tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    flex: 1;
    align-content: start;
    padding: 1rem 0;
}

.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem 1rem;
    background: var(--card-bg);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    font-size: 0.9rem;
    color: var(--text);
    text-align: center;
    min-height: 120px;
}

.tile:active {
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.tile-icon {
    width: 36px;
    height: 36px;
    fill: var(--primary);
}

.tile:nth-child(5) {
    grid-column: span 2;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    border-radius: 50%;
    background: var(--border);
    opacity: 0.4;
    transition: opacity 0.2s, background 0.2s;
}

.status-item.active {
    opacity: 1;
    background: var(--success);
}

.status-item svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s ease-out;
}

.modal-large {
    max-height: 95vh;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s;
    flex: 1;
}

.btn:active {
    background: var(--bg);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-small {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    flex: none;
}

/* Forms */
input[type="text"],
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Key Name Input */
.key-name-input {
    margin-bottom: 0.75rem;
}

.key-name-input input {
    width: 100%;
}

/* Key Display */
.key-display {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.key-display input {
    flex: 1;
    font-family: monospace;
}

/* QR Display */
.qr-display {
    display: flex;
    justify-content: center;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.qr-display canvas,
.qr-display img {
    max-width: 200px;
    height: auto;
}

.qr-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.qr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.qr-item canvas {
    max-width: 100%;
    height: auto;
}

.qr-item span {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* Compose */
.compose-type {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.compose-type label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.compose-info {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Key Status in Compose */
.key-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.key-status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--error);
    flex-shrink: 0;
}

.key-status-icon.active {
    background: var(--success);
}

.key-status-text {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-light);
}

.key-status .btn {
    flex: none;
}

/* Message Display */
.message-display {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    min-height: 150px;
    overflow-wrap: break-word;
}

.message-display h1,
.message-display h2,
.message-display h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.message-display h1:first-child,
.message-display h2:first-child,
.message-display h3:first-child {
    margin-top: 0;
}

.message-display p {
    margin-bottom: 0.75rem;
}

.message-display ul,
.message-display ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.message-display a {
    color: var(--primary);
}

/* Help */
.help-content h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.help-content h3:first-child {
    margin-top: 0;
}

.help-content p,
.help-content ul,
.help-content ol {
    margin-bottom: 0.75rem;
    color: var(--text-light);
}

.help-content ul,
.help-content ol {
    margin-left: 1.25rem;
}

.help-content li {
    margin-bottom: 0.25rem;
}

/* Scanner */
#scanner-container {
    width: 100%;
    min-height: 300px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

#scanner-container video {
    width: 100%;
    height: auto;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 200;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background: var(--error);
}

.toast.success {
    background: var(--success);
}

/* Print Area */
.print-area {
    display: none;
}

@media print {
    /* Alles verstecken */
    html, body {
        background: white !important;
    }

    #app,
    .modal,
    .toast,
    header,
    .tiles,
    .status-bar {
        display: none !important;
    }

    /* Print-Bereich anzeigen */
    .print-area {
        display: block !important;
        position: static !important;
        width: 100% !important;
        visibility: visible !important;
    }

    .print-area * {
        visibility: visible !important;
    }

    .print-page {
        width: 210mm;
        height: 297mm;
        padding: 10mm;
        page-break-after: always;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
        gap: 5mm;
        box-sizing: border-box;
    }

    .print-item {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        border: 1px dashed #ccc;
        padding: 5mm;
        box-sizing: border-box;
        overflow: hidden;
    }

    .print-item img {
        max-width: 100%;
        max-height: 90mm;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    .print-item span {
        margin-top: 3mm;
        font-size: 12pt;
        color: #333;
    }
}

/* Desktop adjustments */
@media (min-width: 600px) {
    .modal-content {
        border-radius: var(--radius);
        margin: auto;
    }

    .modal {
        align-items: center;
    }

    .tiles {
        grid-template-columns: repeat(3, 1fr);
    }

    .tile:nth-child(5) {
        grid-column: span 1;
    }
}
